scorrpeio
Full Member level 5
Hi...
I have written code for timer0 in which everytime TMR0 overflows...it plays buzzer.
However, I didnt use ISR. I used this...
This is working fine.
However, I want to achieve same, using Timer Interrupt.
I tried with this...
I had activated the Global and TIMER0 inetrrupts. But, execution never went into isr loop. I have never used isr in pic. I guess, I could not write it properly. Can anyone let me know, why does it not work? (I have gone through different threads on this site to write the above routine.)
I have written code for timer0 in which everytime TMR0 overflows...it plays buzzer.
However, I didnt use ISR. I used this...
Code:
void EnableTimer (void)
{
unsigned int Cnt_15min = 2;
TRISCbits.TRISC2 = 0; //Set BUZZER pin as o/p pin
PORTCbits.RC2 = 0; // Keep BUZZER OFF
TMR0L = 0x00;
T0CON = 0x07; // prescalar of 1:256; internal clock; 16 bit mode
// Timer disabled
// INTCONbits.GIE = 1; //Enable Global Interrupt
// INTCONbits.TMR0IE = 1;//Enable Timer0 Interrupt
while( Cnt_15min )
{
T0CONbits.TMR0ON = 1; //Start Timer0
while (INTCONbits.TMR0IF == 0 );
{
// PORTB = 0b00000000;
INTCONbits.TMR0IF = 0;
}
Cnt_15min--;
T0CONbits.TMR0ON = 0; //Disable Timer
}
PORTCbits.RC2 = 1; //BUZZER ON
PORTCbits.RC2 = 0;
GetTemperatureValue();
}
This is working fine.
However, I want to achieve same, using Timer Interrupt.
I tried with this...
Code:
#pragma code low_vector = 0x18
void high_ISR (void)
{
_asm goto timer0_isr _endasm
}
#pragma code
#pragma interrupt timer0_isr
void timer0_isr(void)
{
INTCONbits.TMR0IE = 0; //Disable Timer 0 Interrupt
INTCONbits.TMR0IF = 0; //Clear Timer 0 Interrupt Flag
PORTB = 0b00000000;
}
I had activated the Global and TIMER0 inetrrupts. But, execution never went into isr loop. I have never used isr in pic. I guess, I could not write it properly. Can anyone let me know, why does it not work? (I have gone through different threads on this site to write the above routine.)