I m trying to generate a 1 minute interrupt using
pic24F seires… To be specific PIC24Fj64GA306
Here is the code snippet
#include "xc.h"
#include "newxc16_header.h"
void TimerInit(void);
void __attribute__((__interrupt__)) _T1Interrupt(void);
void main()
{
ANSB = 0x0000;
TRISBbits.TRISB0 = 0;
TRISBbits.TRISB1 = 1;
TRISBbits.TRISB2 = 1;
TRISBbits.TRISB3 = 1;
TRISBbits.TRISB4 = 1;
TRISBbits.TRISB5 = 1;
TRISBbits.TRISB6 = 1;
TRISBbits.TRISB7 = 1;
TRISBbits.TRISB8 = 1;
TRISBbits.TRISB9 = 1;
TRISBbits.TRISB10 = 1;
TRISBbits.TRISB11 = 1;
TRISBbits.TRISB12 = 1;
TRISBbits.TRISB13 = 1;
TRISBbits.TRISB14 = 1;
TRISBbits.TRISB15 = 1;
TimerInit();
T1CONbits.TON = 1; //start the timer
while(1)
{
}
}
void TimerInit(void)
{
PR1 = 0x1FFF; //8191
IPC0bits.T1IP = 5; //set interrupt priority
T1CONbits.TCKPS = 0x03; //timer prescaler bits
T1CONbits.TCS = 0; //using FOSC/2
IFS0bits.T1IF = 0; //reset interrupt flag
IEC0bits.T1IE = 1; //turn on the timer1 interrupt
}
void __attribute__((__interrupt__, auto_psv)) _T1Interrupt(void)
{
T1CONbits.TON = 0; //stop the timer
LATBbits.LATB0 = ~LATBbits.LATB0; //Toggle output to LED
IFS0bits.T1IF = 0; //reset the interrupt flag
T1CONbits.TON = 1; //start timer
}
For testing purpose i m trying to generate Timer interrupt after every 1 sec…
But the issue is i m not able to generate any interrupt.
Please help me.
Thanks in advance
Best Answer
I found that PIC24f controller generates interrupt max for 4 sec, using external oscillator of 8MHz. so i m generating an timer interrupt for 1 sec and calculating secs... once it is done for 1 min i do the process.... here is the code snippet
the above code is for timer isr
Timer init
Timer code in main