Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
timer interrupt not working
07-12-2013, 10:38 PM,
#1
timer interrupt not working
Win 8
Pinguino X.4

The following simple blinking code works properly with Pinguino beta 9-05 but does not work with Pinguino-X4-EasyPack-Win32-Rev952-v02-2013-12.

Could you help me, please? Thank you.



u8 counter = 0;

void setup(){
T2CON = 0b00010111; //48MHz /4 /16prescaler /3postscale = 250KHz
PR2 = 249; //interrupt frequency = 250KHz /250 counts = 1KHz
PIE1bits.TMR2IE = 1;
INTCONbits.PEIE = 1;
INTCONbits.GIE = 1;
}

void loop(){}

void UserInterrupt(){
if (PIR1bits.TMR2IF){
PIR1bits.TMR2IF = 0;
counter++;
if ((counter == 99)){ //blinking frequency = 1KHz /100 = 10Hz
counter = 0;
PORTAbits.RA4 = !PORTAbits.RA4;
}
}
}
Reply
08-12-2013, 04:06 AM,
#2
RE: timer interrupt not working
Looks like a linking issue.
Reply
08-12-2013, 09:12 AM,
#3
RE: timer interrupt not working
(08-12-2013, 04:06 AM)niki_m Wrote: Looks like a linking issue.


Thank you for the reply. Anyway, the board links correctly, other firmware loads and works properly (es. classic blinking with delay in the main loop).
Any other suggestion?
Reply
09-12-2013, 11:05 AM,
#4
RE: timer interrupt not working
void UserInterrupt() : try void interrupt() instead.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)