Hey guys,
I'm working with the MSP430F2617 running at a clockspeed of 3,9 Mhz. I'm using the Contiki OS on it to experiment in the WSN domain.
I connected a light sensor to an interrupt pin and wanted to read out the frequency (number of pulses/interrupts generated in one second). For low frequencies my program doesn't encounter problems and can count the exact number of pulses. However, when the frequency goes to around 70, 80, 90 kHz It start reading out completely wrong values. Above a frequency of 90kHz the µC starts to have problems and seems to reboot itself and is not working properly.
I was now wondering why this was happening. Can the µC not handle the interrupt frequencies above 70 kHz because they are generated too fast, or is there something happening in the register? Because the register in which I increment the number of pulses is 16 bit so 65536 pulses which is close to the frequency of 70kHz where things go wrong.
How can I compute or now the maximum number of interrupts? I looked in the data sheet to see how many cycles an instruction takes, but I can not guess how many instructions there are executed in the interrupt routine.
The interrupt routine is very short:
interrupt(PORT2_VECTOR)
irq_p2(void)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);
P2IFG = 0x00;
puls = puls+1;
leds_toggle(LEDS_GREEN);
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
Hope someone can give me an answer.
Best regards!