I'm trying to blink diode, using timer0 MR0 irq. The problem is that the irq works only one time. I see diode is just blinking once and nothing else.
I localized the issue and here's the code:
#include <lpc23xx.h> void t0_irq() __irq { if(T0IR&1) { T0IR=1;//reset irq if(FIO0PIN & (1<<9)) //if pin on { FIO0CLR = (1<<9); //pin off } else { FIO0SET = (1<<9);//else pin on } } } int main() { //setup diode SCS |= 1; //enable FIO PINSEL0 &=~0x000C0000; FIO0DIR |= (1<<9); FIO0SET = (1<<9); //setup timer0 PCONP |= (1 << 1); // power up timer 0 T0CTCR = 0; // timer only mode */ T0TCR = 0; // disable timer 0 PCLKSEL1 &= ~0x0000000C; PCLKSEL0 |= 0x00000004; // timer 0 clock = PCLCK T0IR = 0xFF; // reset irq flag T0PR = 0x00208D55; // prescaler T0MR0 = 5; // match register 0 // configure VIC VICIntEnClr |= (1 << 4); // irq disabling VICIntSelect &= ~(1 << 4);// IRQ interrupt //VICVectPriority4 = 2; // priority VICVectCntl4 =2; // (i use old naming convention here) VICVectAddr4 = (unsigned long)&t0_irq; // ISR address VICIntEnable |= (1 << 4); // irq enable T0MCR |= 0x03; // irq and TC reset on MR0 T0TCR = 0x01; // start timer while(1) { } }
Hi Ivan,
I'm not familiar with the LPC2387, but I am very familiar with LPC214x parts, and I imagine some of the issues are the same. I have two observations :-
1) Normally, with FastGPIO, it is necessary to unmask the relevant I/O Pins before you can use them. See the FIO0MASK register.
2) Your interrupt handler doesn't appear to acknowledge the interrupt at the VIC. The consequences of this will vary depending on how your interrupts are configured but will generally either result in the interrupt handler only being called once, or it being called continuously.
Hope this helps.
Just posted the reply above and all the other replies appeared - there were no others when I looked a moment ago.
Have the forum gremlins returned ?
Well, the strange thing is that in Keil's emulator everything looks fine. But on real hardware, the ISR was called only once (IMHO If it would called continiously, it would be easier to find my bug ). :)
What is strange? That an emulator is not a 100% perfect match for the internals of the ARM chip?
"What is strange? That an emulator is not a 100% perfect match for the internals of the ARM chip?"
Oh no ... I can sense an imminent comment on a pet topic from Erik coming ;)