mig29fulcrum
Junior Member level 1
Hi...
I have written code for timer0 in which every time TMR0 overflows,it toggles RC0,but i used TMR0IF to indicate that TMR0L and TMR0H are overflow,but when overflow occurs pic doesn't rise its TMR0IF flag and TMR0L resets to 00(TMR0H stays on 0xff). I will appreciate if you help me with this.
Thank you:-D
I also have same problem with the following code when i use timer0 as 16-bit one(in 8-bit mode everything is ok).
I have written code for timer0 in which every time TMR0 overflows,it toggles RC0,but i used TMR0IF to indicate that TMR0L and TMR0H are overflow,but when overflow occurs pic doesn't rise its TMR0IF flag and TMR0L resets to 00(TMR0H stays on 0xff). I will appreciate if you help me with this.
Thank you:-D
Code:
#include<P18F2550.h>
#pragma config FOSC=INTOSC_EC
#pragma config WDT=OFF
void main()
{
TRISCbits.TRISC0=0;
OSCCON=0x02;
OSCTUNE=0X80;
while(1)
{
T0CON=0x08;
TMR0L=0XF0;
TMR0H=0XFF;
INTCONbits.TMR0IF=0;
T0CONbits.TMR0ON=1;
while(INTCONbits.TMR0IF==0);
PORTCbits.RC0^=1;
T0CONbits.TMR0ON=0;
}
}
Code:
LIST P=PIC18F4550
#INCLUDE P18F4550.INC
CONFIG FOSC=INTOSC_EC
CONFIG IESO=ON
CONFIG WDT=ON
ORG 0H
BCF TRISC,0
MOVLW 0X02
MOVWF OSCCON
MOVLW 0X08
MOVWF T0CON
AGAIN
MOVLW 0XF0
MOVWF TMR0L
MOVLW 0XFF
MOVWF TMR0H
BCF INTCON,TMR0IF
BSF T0CON,TMR0ON
CHECK
BTFSS INTCON,TMR0IF
BRA CHECK
BCF T0CON,TMR0ON
BTG LATC,0
BRA AGAIN
END