Hi,
Using R7FA6E10F2CFP, FSP Configurator Version 5.5.0 and IAR EWARM 9.20.2. This problem is reproducable with a very simple project without any OS.
We are using the r_agt timer to measure the pulse period of an input signal (frequency 100Hz ... 5kHz) connected to pin P404, by getting interrupts on falling edges and timer overflows. The interrupts are handled in a function based on the "AGT Input Capture Example" in the r_agt documentation.
This works fine most of the time, but every now and then it happens that there is no interrupt when a falling edge occurs. This has been verified using an oscilloscope and some debugging code.
It seems like the falling edge interrupt is missing in cases when the timer overflow interrupt (TIMER_EVENT_CYCLE_END) occurs at (or very close to) the falling edge (TIMER_EVENT_CAPTURE_A).
In the generated interrupt service routine agt_int_isr() in r_agt.c, it is checked if there was a timer overflow or not, but it is not explicitly checked if there was a falling edge.What happens if both timer overflow and falling edge are active at the same time?Is agt_int_isr() then called twice (does not seem so), or can it somehow be checked if both interrupts are active?
If there is no obvious explanation for this, I can try to create a simple project for the FPB-RA6E1 development board to demonstrate the problem.
Below is the FSP configuration:
Hello JohVai,
A typical sample code that can be implemented on your case is the below:
This callback on your case is the receive_f_falling_edge callback that you have defined. If you set breakpoints inside the two if cases, you will be able to check if both of the interrupts happen.
Also, you asked what happens if both of these interrupts are enabled simultaneously. Usually, one of the two interrupts will come with a time difference, because of the very fast counter analysis of the AGT compared to the measured signal. The code above has been designed to check if the underflow comes firstly or not and give to the user the correct pulse time value regarding any pre- existing underflow.
On a GPT FSP module you can define the priorities of the two interrupts, in order to say to the cpu which interrupt will be serviced firstly (in case of received the two interrupts the same moment), but this doesn't exist for the AGT module. But, it isn't significant, if you implement something like the code above, because it checks both of the two cases.
Neverthless, can you send a simple project to make some tests?
Regards,
AL_Renesas
Hello, and thanks for looking into this.
My callback receive_f_falling_edge is according to this example, always checking for both interrupts. Most of the time both interrupts occur as expected. But sometimes it happens that there is no falling edge interrupt although there is a falling edge in the signal, i.e. one single falling edge is missed.
But I will create a simplified example project for the FPB-RA6E1 development board that demonstrates the problem. I will provide that still this week.