volatile uint32_t counter_timer = 0;
void __USER_ISR myISR() {
counter_timer++;
clearIntFlag(_TIMER_3_IRQ);
}
void __USER_ISR myISR_timer_four() {
clearIntFlag(_TIMER_4_IRQ);
TMR4 = 0x16E3600;
Serial.print("hi\n");
if(PORTAbits.RA10 != 1){
LATAbits.LATA10 = 1;
}
else{
LATAbits.LATA10 = 0;
}
}
void setup{
T3CONbits.TCS = 0b0; // Timer Clock Source Select bit
T3CONbits.TCKPS = 0b000; //0b111; // Timer Input Clock Prescale Select bits
T3CONbits.ON = 0b1; //0;//0b1;
asm("nop \n");
T4CONbits.TCS = 0b0;
T4CONbits.TCKPS = 0b000;
T4CONbits.T32 = 0b1;
TMR4 = 0x16E3600; // half of 48mHz.
T4CONbits.ON = 0b1;
setIntVector(_TIMER_3_VECTOR, myISR);
setIntPriority(_TIMER_3_VECTOR, 4, 0);
clearIntFlag(_TIMER_3_IRQ);
setIntEnable(_TIMER_3_IRQ);
setIntVector(_TIMER_4_VECTOR, myISR_timer_four);
setIntPriority(_TIMER_4_VECTOR, 1, 0);
clearIntFlag(_TIMER_4_IRQ);
setIntEnable(_TIMER_4_IRQ);
TRISAbits.TRISA10 = 0; // Fubarino onboard yellow led
}
void loop() {
delay(500);
Serial.println(counter_timer);
Serial.println(TMR4, DEC);
}
Hi,
i wanna use multiple interrupts, i got the information from a document i got from: Majenko Technologies. the interrupt bound to Timer3 works, this was the example code in the pdf. now i "assembled" a second interrupt bound to timer4, copy, paste and adapt, but that isn't working.
i can print the "content" of the timer4 register and it's running.
have i done something wrong? search engine didn't yield a answer.
1 Answer 1
The problem was that you need to combine the even and the next odd timer (see datasheet of the microchip pic you're using) to form a 32 bit timer.