Page 51 - DEC40053 Ebook_Timer
P. 51

example:-






                Find the time delay and write a C18 program

                to toggle all the bits of PORTB continuously

                with  some  delay.  Use  Timer0,  16-bit  mode,


                and  no  prescaler  options  to  generate  the


                delay (square wave of 50% duty cycle) with

                TMR0H and TMR0L is FFF2








                Answer:-




                Fosc/4 = 10MHz/4 = 2.5MHz


                T = 1/Fosc = 1/2.5MHz = 0.4us





                NOC = (FFFF-FFF2) + 1 = 0E(hex) = 14(dec)





                Delay = NOC x T x Prescaler

                           = 14 x 0.4us x 1 = 5.6us





















                                                          -42-
   46   47   48   49   50   51   52   53   54   55   56