c - C8051F330/320 Delay with Timer Function not working -


i using silicon labs 8051 mcus. below delay function timer examples came ide.

//----------------------------------------------------------------------------- // t0_wait_ms //----------------------------------------------------------------------------- // // return value : none // parameters   : //   1) unsigned char ms - number of milliseconds wait //                        range full range of character: 0 255 // // configure timer0 wait <ms> milliseconds using sysclk time // base. // void t0_wait_ms (unsigned char ms) { tcon &= ~0x30;                      // stop timer0; clear tf0 tmod &= ~0x0f;                      // 16-bit free run mode tmod |=  0x01;  ckcon |= 0x04;                      // timer0 counts sysclks  while (ms) {   tr0 = 0;                         // stop timer0   th0 = -(sysclk/1000 >> 8);       // overflow in 1ms   tl0 = -(sysclk/1000);   tf0 = 0;                         // clear overflow indicator   tr0 = 1;                         // start timer0   while (!tf0);                    // wait overflow   ms--;                            // update ms counter }  tr0 = 0;                            // stop timer0 } 

i changed input parameters char integer give longer delays.when checked not giving accurate delays


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -