interrupts in C

Questions about the BASICtools and MakeItC
Post Reply
YahooArchive
Posts: 1463
Joined: Fri Oct 19, 2012 5:11 am

interrupts in C

Post by YahooArchive » Thu Oct 25, 2012 9:52 pm

> Does anyone know if there's a way to do interrupts in C? I'd like to
> set a timer and have a routine called when it pops. I don't need
> HWPWM or UART services, so there are some timers available.

Check the init_coridium() routine in coridium.c

While it is #ifdef'd out when not targeting the ARMweb, that same code
will work for the ARMexpress, with slight modification. The timers
are a little different on the 2103/2106

Here is the code that initialized timer interrupt for 2103/2106


void INT_T1MR0(void) { // timer interrupt
callYourCodeHere()
T1_IR = 1; // clear interrupt
VICVectAddr = 0; // Acknowledge Interrupt
}

void f_intTIMER (int elapsedTime) {
disableIRQ();

// Setup PWM Compare-Match Interrupt
T1_TC = 0;
T1_PC = 0;
T1_MR0 = elapsedTime - 1; //user match in ms, count from 0
T1_MCR = 3; // Interrupt and Reset on MR0

T1_PR = PCLK/1000-1; //1 ms prescaler
T1_TCR = 1; // TIMER1 timer Enable, turn on ethernet irq

VICVectAddr5 = (unsigned long)INT_T1MR0;
VICVectCntl5 |= 0x25; // use it for TIMER1 Interrupt:
VICIntEnable |= 0x20; // Enable TIMER1 Interrupt

enableIRQ();
}

Your interrupt service code should be added in ISR.c
The interrupt settup can go anywhere else (this is due to the
optimizations on ISR are minimal, and often those optimizations break
interrupt code)



Post Reply