On Fri, 18 Mar 2005 09:51:21 +0100, rseku wrote:

>Has anyone tried to dig into usart.h in buffered usart example.
> From my view it looks, that precomiled directives are useless which 
>always gives zero (or I don't understand it)
>the code below calculates USART0_BAUD_DIV and then subtract from the 
>same formula. It looks to me like x - x, and it always give 0;
>Am I worng?

>#define USART0_BAUD_DIV(baud) (uint16_t)(USART0_BRCLK / (baud))
>///////////////////////////////////////////////////////////////////////////////
>// the following are used to calculate the UMOD values at compile time
>#define CMOD_0(baud) ((USART0_BRCLK / (baud))-USART0_BAUD_DIV(baud))


>-------------------------------------------------------

It is floating point math performed by the compiler.  USART0_BAUD_DIV
is an integer.  (USART0_BRCLK / (baud)) by itself, is float and can
have a fractional part.

Regards
-Bill Knight
R O SoftWare

PS - While the math uses floating point, it is all performed by the
compiler.  Only integer values are present in the code.



Reply via email to