[SOLVED] Question about GPIO interrupt and timer count
Hello!
I have a 100 kHz external singal connected to a GPIO input (PD7), at the moment I am generating the signal with a good signal generator so it has very little jitter. What I want to do is measure the length of the period of each one of 4096 succesive periods without skipping any.
My program is very simple:
I have TIMER 2 running at full speed in 32 bit mode. Rising edge interrupts at PD7 call a function that saves the timer value first in a static variable, then clear the timer and save the read value in a static uint32_t [4096] buffer, when the buffer is full I deactivate the interrupts and the process is finished. In a later stage, I send the stored values through the LPUART1 (that is connected to the ST-Link) to a computer. While the periods is being measured nothing else is taking place, the main program is stuck in a case value waiting for a variable to change.
What I am seeing is that the periods are measured correctly except that every 700us approximately, one period value is much longer and another adjacent much shorter. It gives the impression that something happened when the interruption was being serviced. I tried many things like: making sure no other interrupts are activated and the basic CPU interrupts set to minimum priorioty (PD7 at maximum priority). I also changed the optimization levels to see if the way the code was compiled had something to do.
I was wondering if the ST-Link could be interfering in some way? Creating somehow interrupts?
Thank you.
R.
PS: I am working with the NUCLEO-L4R5ZI board and I am using the 8 MHz clock generated by ST-Link because its more accurate than the internal RC. Unfortunately at the moment I dont have the code at hand but if it is relevant I can post it.
