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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/11/20 21:10
Read: times


 
#190967 - Keil C51 Bug
I think I found a bug in the pre-processor for C51 v9.52. I'm using uVision V4.72.9.0

In testing some baud rates I found that the table values calculated by the pre-processor are wrong in one instance. All of the baud rate generator values are correct except for 19600.


#define  SYS_CLK   12000000L           // Tcyc = 1/12MHz = 83ns

/*
| Baud rate to UART 1 baud rate generator reload conversion. 
|
|                       SYSCLK
| Reload = 65536 - ------------------  
|                  PRE * 2 * baudrate
|
| Assume SYSCLK is 12MHz and Baud Rate Prescaler Select == 11 (/1).

*/
#define  NUM_BAUDRATES  9

static U16 code BaudParams[NUM_BAUDRATES] =
   {
   65536 - (SYS_CLK/(1*2*1200)),       // 0xEC78 (exact)
   65536 - (SYS_CLK/(1*2*2400)),       // 0xF63C (exact)
   65536 - (SYS_CLK/(1*2*4800)),       // 0xFB1E (exact)
   65536 - (SYS_CLK/(1*2*9600)),       // 0xFD8F (exact)
   65536 - (SYS_CLK/(1*2*19200)),      // 0xFEC7 (0.16%) // COMPILER BUG? Gives 0x01BA. :(
   65536 - (SYS_CLK/(1*2*38400)),      // 0xFF64 (0.16%)
   65536 - (SYS_CLK/(1*2*57600)),      // 0xFF98 (0.16%)
   65536 - (SYS_CLK/(1*2*115200)),     // 0xFFCC (0.16%)
   65536 - (SYS_CLK/(1*2*31250))       // 0xFF40 (exact)
   };

#if(65536 - (SYS_CLK/(1*2*19200)) != 0xFEC7)
   #warning "Compiler preprocessor BUG at UART1 Baud rate 19200!"
#endif

 


If anyone wants to double check this and other versions, that would be great. Also not sure if it's worth trying to find the Keil/Arm forum wherever it's gotten to...





List of 6 messages in thread
TopicAuthorDate
Keil C51 Bug            01/01/70 00:00      
   integer overflow            01/01/70 00:00      
      Same result (bad)            01/01/70 00:00      
         Spreadsheet Analysis             01/01/70 00:00      
         please try again            01/01/70 00:00      
            Yay            01/01/70 00:00      

Back to Subject List