Page 47 - DEC40053 Ebook_Timer
P. 47
Finding Values to be
Loaded into the Timer
Example:
Assuming XTAL=10MHz and no prescaler with a
period of 10ms
1. Divide the desired value of time delay by 0.4us
;;Tocs=1/(Fosc/4)=0.4us ; T=10ms/2=5ms
::Clocks=5ms/0.4us=12500(dec)
2. Perform (65535-n)+1. where n is the decimal
value ;; NOC=(65535-12500)+1 = 53036(dec)
= CF2C(hex)
3. Convert the result to hex, where YYXX is the
initial hex value to be loaded into the timer's
register ;; 53036(dec)= CF2C(hex)
4. Set TMR0L=XX and TMR0H = YY
;;TMR0H=CF(hex) AND TMR0L=2C(hex)
-38-