Hi Prescaler/Lo timer or Lo Prescaler/Hi timer ???

Status
Not open for further replies.

fenderman

Member
Hi All,
Just a curiosity, I'm using Timer 0 as a 'very rough' base interrupt timer to obtain a 2ms interrupt.
I can achieve the correct timing with several different values in the Pre-scaler and the Timer0 re-loads.
I was just wondering if there is any 'rule of thumb' or advantages/disadvantages in using a High Pre-scaler value and Low Timer reload count, or Low Pre-scaler and High Timer reload count.
Any comments would be appreciated.

Roy
 
Whenever you reload timer zero the prescaler is reset to zero. This can cause a wide range of errors and needs to be accounted for in timer calculations. A much better way to get a 2mS interval is using timer 2. Unless you have a weird crystal frequency timer 2 can be setup to generate the interrupt without any user intervention (no reloading).

Mike.
 
Cheers Mike,

I am already using Timers 1 and 2 for other interrupts, hence the reason for using Timer 0, especially as I'm only after a 'near enough' 2ms that is not critical.
I did'nt realise that the pre-scaler gets reset to zero though, I'll have to bear that in mind for future, although I probably would'nt use Timer 0 for time critical applications anyway.
Nigel indicated that Timer 0 is mainly for backward compatibility and that his personal favourite is Timer 2.
I agree that Timer 1 and Timer 2 being 16 bit timers seem much more suitable and flexible, but just wondered if there were any advantages in the prescaler to timer values being Hi/Low or Low/Hi.

Roy
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…