view code_part1/OSTC_code_asm_part1/spbrgselect.inc @ 167:cb055a7d75f3

+ Use overlay local vars. + Make all private functions static. + Merge calc_tissue 2sec and 1min + Merge sim_tissue 1min and 10min + Expose basic display utilities for c-code. + Prepare stand-alone utilities for p2_main.c testing platform. + New c utility: int read_custom_function(cf#)
author JeanDo
date Mon, 24 Jan 2011 23:31:57 +0100
parents 96a35aeda5f2
children
line wrap: on
line source

RoundResult SET 0				; Rounding function.  RoundResult = Round(aa/bb)

Round	macro aa,bb

	LOCAL rr = aa/bb

	LOCAL d1 = aa - rr*bb

	LOCAL d2 = (rr+1)*bb - aa

RoundResult = rr

	if d1 >= d2

RoundResult++

	endif

	endm



AbsResult SET 0

Abs		macro nr

	if nr>=0

AbsResult = nr

	else

AbsResult = -nr

	endif

	endm

		

	Round xtal,(16*baud)

spbrg_value EQU RoundResult-1



	Round xtal,(16*(spbrg_value+1))

baud_real EQU RoundResult

	Abs(baud_real-baud)

errpercent EQU AbsResult*100/baud

	if errpercent > 4

		ERROR big error in baudrate: #v(errpercent)%

	endif

	if errpercent >= 2

		messg baudrate not exact: #v(errpercent)%

	endif