TMR0 PIC18F458 question

Status
Not open for further replies.

gzorzi

Junior Member level 1
Joined
Jul 24, 2002
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
123
I use PIC18F458 with 20MHZ clock.
I set TMR0L = 00 and I wait = FF. I increment it with clock (I think internal /4) and 1/256(prescale). What is it the time duration between
00 to FF ?
Thanks
 

hi gzorzi,

20 MHz has period of 50ns so if timer0 is in 8 bit timer mode then you have
50 ns * 4 * 256 * 256 = 13107200 ns or about 13 ms

best regards
 

Thanks
 

I use picbasic pro with 18F458 and my program use the bootloader option.
DEFINE LOADER_USED 1

'enabled interrupt timer0
INTCON=%10100000
'enabled timer0
T0CON =%10000111
on interrupt goto gest_int

main:


goto main

disabled
gest_int:
'disabled timer
T0CON =%00000111
'reset timer
TMR0L=$00
TMR0H=$00
'enabled timer
T0CON =%10000111

if portd.2=1 then
low portd.2
else
high portd.2
endif
resume
enabled

1) 18F458 has 2 interrupt address 0080H and 0018H
the on interrupt goto xxx use 08H or 18H

2) I wait on portd.2 one signal 3.3 sec high and 3.3 sec low but this aspected signal there isn't
I see the high level very speed and the low level large and the period isn't regular

Do you have some suggestion ?
thanks
 

hi gzorzi,
I’m not familiar with picbasic pro but:

1) for high and low priority interrupts handling you have to see picbasic manual.
2) what is the value of IPEN bit in RCON register ?
3) there is no need to disable, reset and reenable TMR0 in interrupt handling routine;
4) use LATD rather PORTD register to toggle PORTD2 bit i.e. -> if latd.2=1 then …

best regards
 

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