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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/27/05 09:06
Read: times


 
#95998 - I was being carelessly loose............
Responding to: ???'s previous message
Sorry. I was being carelessly loose with terms when I referred to the #define macros and the subsequent computations that are done with them as all the work of the pre-processor alone. I actually meant to include the compiler in the process too!!

When I made my original post I was trying to report on my own personal experience with the IAR compiler (the AVR version) and the Keil Compiler (the 8051 version). I now have to say that I cannot rightly recall if the actual Keil C51 compiler can reduce carefully crafted floating point arithmetic expressions to simply integer expressions for run time use. To determine if it can or to see if such expressions automatically force inclusion of floating point library would require futher testing on my part. On the other hand the I can say for sure that code like that shown below definately results in integer constants in the run time code when the IAR AVR compiler is used.
#define AD_REF             3.0          // A/D converter reference voltage
#define AD_CNT_RANGE    1024.0          // count range of the A/D converter
#define VIN_R1          47.5E3          // value of upper resistor in the VIN divider 
#define VIN_R2          10.0E3          // value of lower resistor in the VIN divider
#define VIN_OFF            0.3          // VIN drop through diode to the VIN divider
#define VIN_MIN            6.5          // minimum VIN volts for device operation
#define VIN_MAX           13.5          // maximum VIN volts for device operation
#define VIN_HYS            0.2          // hystersis of VIN voltage for recovery
#define VIN_MIN_CNT ((unsigned int)(((((VIN_MIN - VIN_OFF) * VIN_R2)/(VIN_R1 + VIN_R2))*AD_CNT_RANGE)/AD_REF))
#define VIN_MAX_CNT ((unsigned int)(((((VIN_MAX - VIN_OFF) * VIN_R2)/(VIN_R1 + VIN_R2))*AD_CNT_RANGE)/AD_REF))
#define VIN_HYS_CNT ((unsigned int)((((VIN_HYS * VIN_R2)/(VIN_R1 + VIN_R2))*AD_CNT_RANGE)/AD_REF))


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