Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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




List of 31 messages in thread
TopicAuthorDate
defination under Keil            01/01/70 00:00      
   int/float            01/01/70 00:00      
   IAR PreProcessor VS Keil            01/01/70 00:00      
      confusion            01/01/70 00:00      
         just doing text subistituons I guess            01/01/70 00:00      
            un            01/01/70 00:00      
               preprocessor            01/01/70 00:00      
                  Some confusion abounds...            01/01/70 00:00      
                     Wrong again!            01/01/70 00:00      
                        Take is easy...            01/01/70 00:00      
                           The important bit...?            01/01/70 00:00      
         Floating-point not supported in eval            01/01/70 00:00      
      preprocessor maths            01/01/70 00:00      
         I was being carelessly loose............            01/01/70 00:00      
            Keil Test            01/01/70 00:00      
            Save you the trouble            01/01/70 00:00      
               Oh            01/01/70 00:00      
         preproccessor maths            01/01/70 00:00      
            ##########            01/01/70 00:00      
               thats the confusion            01/01/70 00:00      
                  In context            01/01/70 00:00      
                     Thanks            01/01/70 00:00      
                  Think about it            01/01/70 00:00      
   Aside - 'C' #define names            01/01/70 00:00      
      good coding practices            01/01/70 00:00      
   Thank you            01/01/70 00:00      
      Alternatively...            01/01/70 00:00      
         re: Alternatively...            01/01/70 00:00      
      Not a good idea            01/01/70 00:00      
         Not a good idea            01/01/70 00:00      
         floating point in ISRs            01/01/70 00:00      

Back to Subject List