We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello, I am using an MCB900 evaluation board for philips LPC935FA which uses a clock of 7.373MHz. I wanted a 1 second delay so I loaded timer 0 with these values: TH0=0xF1; TL0=0x99 (I used the code architect to get these values). I then used a counter in the software to count this 1,000 times. This ordinarily should give me 1 second delay after which an LED should be switched on. I have used a stop watch to check the accuracy of the timing and it lags behind by as much as 3 seconds. Could anyone help me as to the reason why this happens. Regards, Ade
to count this 1,000 times a guess: non-atomic read Erik
Sorry to bother you again, but what is a non-atomic read.
things like in an ISR an_int_named = ...; in a non interrupt section ... = an_int_named = ; if any variable of more than 8 bits is used both in an ISR and outside it MUST be handled inside disabled interrupt. Erik
"I wanted a 1 second delay so I loaded timer 0 with these values: TH0=0xF1; TL0=0x99" At a glance your reload value doesn't look right for a 12 clock device at the frequency you stated. I'm not familiar with the device you're using so I can't offer the correct numbers, but all you have to do is establish from the datasheet the frequency at which T0 is clocked in relation to the oscillator frequency. It's straightforward to work out the reload value once you know this.
At a glance your reload value doesn't look right for a 12 clock device at the frequency you stated. the OP stated: (I used the code architect to get these values) 1) the 89LPCs are 2 clockers 2) CodeArchitect is GREAT, the values will be correct. Erik
"the 89LPCs are 2 clockers" Like I said I'm not familiar with the device. OP: Post your code!
"if any variable of more than 8 bits is used both in an ISR and outside it MUST be handled inside disabled interrupt." Or, if you don't want to mess up your interrupt latency, re-read the variable until its value is the same on consecutive reads.