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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Grant Beattie
02/14/20 15:58
Modified:
  02/14/20 15:59

Read: 104 times
Irvine, Ca
USA


 
#190972 - Yay
Responding to: Jan Waclawek's previous message
Wow, this is craziness. Today for baseline, I tried to create the original issue (no L) and the defect has moved. I added underscores for visibility.

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

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%)  yesterday's defect, now ok (except rounding)
   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)  today's issue
   };

dump:
 A160 : 12 9D 0A C2 86 7F E8 7E  03 02 9D 0A EC_78 F6_3C
 A170 : FB_1E FD_8F FE_C7 FF_64  FF_98 FF_CC 0F_70 E5 5C

 



Now with the L added for each denominator.

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

dump:
 A160 : 12 9D 0A C2 86 7F E8 7E  03 02 9D 0A EC_78 F6_3C
 A170 : FB_1E FD_8F FE_C8 FF_64  FF_98 FF_CC FF_40 E5 5C


 


Issue resolved and rounding/truncation changed. (I will fix the check too!)

Thanks gang!




List of 6 messages in thread
TopicAuthorDate
Keil C51 Bug      Grant Beattie      02/11/20 14:10      
   integer overflow      Jan Waclawek      02/12/20 01:06      
      Same result (bad)      Grant Beattie      02/12/20 09:45      
         Spreadsheet Analysis       Michael Karas      02/13/20 23:18      
         please try again      Jan Waclawek      02/14/20 15:22      
            Yay      Grant Beattie      02/14/20 15:58      

Back to Subject List