I am trying to measure frequency of two input signals using 2 timers with interrupts on an LPC2368. At the same time the MCU is also sending data over RS232 to a computer. As soon as the frequency of the input signal goes up till 200Khz the serial data transmission stops. LPC2368 has a Vectored Interrupt Controller and is running at 48Mhz. What I think is happening is that as the frequency of the input signal increases the interrupts don't get processed fully before another interrupt happens and the number of interrupts that the MCU has to process keeps on increasing which stalls the main program loop. How many interrupts can stay pending on an LPC2386 if the first ISR hasn't completely been processed and another interrupt happens
Do the math: 48MHz base clock / 200kHz => 240 cycles per interrupt. With the cycle counter (or by hand) you can estimate the time your interrupt needs.It is likely, you are only handling interrupts and nothing more.
As for pending interrupts etc.: Check the TRM, I think it tells more about it.
The MCU does not have cycle count register so I started a timer (running at CPU clock) and the beginning of the interrupt routine and stopped at the end. The value of the timer was 522. Was this approach correct?
Ouch, sorry it is a ARM7TDMI, no cycles counters.
Right. 3rd approach ;-)And you see that you spend too much time in the ISR for a 200kHz interrupt. You can try to tweak either your requirements or go for a MCU with at least 96MHz (but I see you can reach at up to 72MHz with the LPC2368, so why not try this).
Or you go for FIQ and Assembly.
And/or move the interrupt routine into RAM.
View all questions in Classic processors forum