??? 06/26/05 20:04 Read: times |
#95966 - IAR PreProcessor VS Keil Responding to: ???'s previous message |
The IAR Preprocessor is capable of parsing float type data and then converting to integer at the necessary time.
In the case of KEIL the preprocessor is only capable of working in integer (32 bit I believe). Thus in order to handle the type of thing you are doing is to not use 22.1184 as you have shown but to instead use 22118400 and prescale other parts of calculations by powers of 10 so that you can arrive at the intended crystal frequency dependant definitions. Here is an example I have from some C code that is compiled by the Keil compiler to compute the baud rate divisors for a SiLabs C8051F124 project I did recently: #define SYSCLK_FREQ 22118400UL /* 22.1184 MHz */ #define UART0_BAUD 9600UL /* desired fixed baud rate in Bits/Sec */ #define UART1_BAUD 9600UL #define UART0_DIVISOR (65536UL - (SYSCLK_FREQ/(16*UART0_BAUD))) /* for timer 3 */ #define UART1_DIVISOR (256UL - (SYSCLK_FREQ/(12*2*UART1_BAUD))) /* for timer 1 */ Michael Karas |