Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

initializing timer0 in pic 16f84

Status
Not open for further replies.

malak_pal2004

New Member
hay ,
i want my timer to have a 500ms interrupt on overflow interval
fosc is typically 4 MHz so fosc/4=1MHz
desired scale is 500000
max scale by timer 256*256
if we say 4* 125=500 then i need 125 interrupts? each after 4 seconds? 32 prescaling?
if so i will intialize thetimer0 to 131 , but if i want to count backward should it be 125 or 124?

this is my hardware timer code

bcf STATUS,RP1
bsf STATUS,RP0
movlw B'11010100
movwf OPTION
bcf STATUS,RP0
movlw D'131'
movwf TMRO
bcf INTCON,T0IF
bsf INTCON,T0IE
bsf INTCON,GIE
return
and my software timer

five00Ms

movlw 124
movwf BLNKCNT

wait500

btfss BLNKCNT,7
goto wait500
return

my question why 124 not 125?


plz HELP!
 
make your xtal or resonator 4.194304 Mhz

set prescaler for 256 and assign it to tmr0
set tmr0 reload value at 255
set a register to count to 8 inside your interrupt service routine
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top