We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, All!
I am dealing with the most obscure bug I have ever encountered. I am using LPC2144, Keil RTX and MDK 4.60. I have a task waiting for event (forever) that is triggered by a pin state transition. The pin transition is detected with CAP0.0 (P0.22) interrupt and isr_evt_set it executed to continue the task execution. The program works flawlessly until a certain point or until power loss. Afterwards, the interrupt refuses to trigger (led that toggles in the interrupt does not change it's state any more). OS works, tasks schedule correctly and even polling the P0.22 returns correct state. Only the interrupt never happens. In that case, only toggle of the reset line can restore proper functionality of the program. It happens on all three boards I have assembled. I'm starting to think it might also be a HW bug, however, all VCC pins have proper decoupling capacitors and the board has a couple hundreds of uF on the 3.3V line.
Any suggestions would really be appreciated!
Regards,
Matic
No luck. Changing to a series of ifs still never triggers an interrupt after the first powerdown. However, adding the default case with clearing all interrupts in previous switch version miraculously solved the problem. But if that worked this should work too!!! This is one spooky piece of a microcontroller.
__irq void timer0_irq() { int IR = T0IR; // ........................................................................ // Match1 interrupt if (IR==(1<<1)) // match1 (MR1) { isr_evt_set(TSK_CLK_RESUME,t_clock); //Resume clock task to update the display //T0IR=(1<<1); // Clear MR1 Interrupt } // ........................................................................ // Match2 interrupt if (IR==(1<<2)) // match2 (MR2) - Timeout after THRE { TXCLR(); // Clear RS485 TX line T0_MR2DIS(); // Disable Match2 //T0IR=(1<<2); } // ........................................................................ // Capture0 interrupt if ((IR==(1<<4))) // Cap0 interrupt { isr_evt_set(TSK_COMMAND_REQUEST_ISR,t_command); // Slave requested action if (t_idleled != 0) // Task t_idleled exists isr_evt_set(TSK_SIGNAL_LED,t_idleled); // Signal Sync1 transition T0_CAP0DIS(); // Disable triggering until response is provided //T0IR=(1<<4); } T0IR=(0xFF); // All cases handeled, clear all interrupt flags VICVectAddr = 0; /* Acknowledge Interrupt */ }
This is getting more and more ridiculous. Adding CAP0.3 to do the same thing as CAP0.0 solves the problem. And all I did were these 4 changes :
Initialization
//T0CCR = (1<<0); T0CCR = (1<<0) | (1<<9); //PINSEL1 |= (2<<12); PINSEL1 |= (2<<12)|(2<<26);
Global definitions
#define T0_CAP0EN() T0CCR |= (1<<2) | (1<<11) #define T0_CAP0DIS() T0CCR &= ~(1<<2) | (1<<11) //#define T0_CAP0EN() T0CCR |= (1<<2) //#define T0_CAP0DIS() T0CCR &= ~(1<<2)
T0 Interrupt
// Capture0 interrupt if ((IR==(1<<4)) || (IR==(1<<7))) // Cap0 or Cap3 interrupt //if ((IR==(1<<4)))
Any ideas?
And even more... If I and prepare both CAPTURE channels as mentioned above, but keep old definitions (enable only the CAP0 interrupt), the program does NOT work after reset/programming, but it DOES work after power cycle.
Should I start giving up?
[ Should I start giving up? ]
I think that, you already get everything you may need to solve this problem. 1. You can reproduce the problem 100% successfully. 2. You already find some clues about the problem, something like an unexpected interrupt was triggered.
What you need is just to take a break, calm down, then get back with patience.