cancel
Showing results for 
Search instead for 
Did you mean: 

Alternative option for GPIO External Interrupt for fast signals

sreyas40
Senior

Hello, 

I'm using Nucleo H723ZG.

In my project, i need to detect a rising edge to trigger a callback. What i have done is that i setup a GPIO as external interrupt, and i verified the code by manually connecting and releasing from 3v3 pin. The actual signal i want to trigger is high for approx 38ns , and the callback is not triggering.

What is the best solution for this?

System operating at - 480MHz

Peripheral clocks - 60MHz

Timer clocks - 120MHz

 

edit : Can i use Timer input capture for that, does using it in one pulse mode mean it detects a rising edge and then resets until next trigger (as a slave timer)

edit: I tried the timer input capture too, but still same effect, I used the HAL_TIM_IC_CaptureCallback , One pulse mode is enabled, it is in slave mode, I even applied a 1MHz signal still callback is not triggering, when i applied a 100KHz signal the callback triggers properly. 

edit: upto 400KHz signal the below callback is properly triggering

void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim){
	if(htim == &htim4){
	strcpy(uart_buf,"triggering - meh\n\r");
	HAL_UART_Transmit_DMA(&huart3,(uint8_t*)uart_buf, sizeof(uart_buf));
	}
}

edit: It seem the Interrupts were triggering, but due to large number of interrupts, the MCU was not able to execute anything. What i want to achieve is that i want to initiate SPI in DMA mode after it overflows (update event), will enabling DMA for timer help?

24 REPLIES 24
mƎALLEm
ST Employee

Hello,

38ns high, and what about the low duration?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Ozone
Principal II

Check the datasheet / reference manual, but all GPIOs have configurable glitch filters implemented.
Here an example I had at hand, for another MCU :

Ozone_0-1762420511912.png

GPIO speed and glitch filter settings are not neccessarily related to the core clock frequency.

about 570ns low.

I even applied a 1MHz signal still not working, but for 100KHz it is working, but i need it to work for fast signals

I could only find this in the datasheet

sreyas40_0-1762425302671.png

 

 

What about the timer input capture, is it same like GPIO EXT Interrupt.

I even applied a 1MHz signal still not working, but for 100KHz it is working, but i need it to work for fast signals.

waclawek.jan
Super User

Make sure your signal reaches the pin you intend to. The simplest method is to set that pin as GPIO Out and toggle and observe at the point where you connect your signal. 

Make sure the signal has voltages for valid logic levels for your VDD.

Write a minimal but complete compilable program exhibiting the problem and test with that. By minimal I mean no RTOS, no fluff, just clock initialization, setup of the interrupt, and a means to observe the interrupt to occur (e.g. incrementing a volatila counter which is observed in debugger).

JW

the signal is generated by another timer (PWM) , i verified the signal in a logic analyzer. 

I again changed the signal to 100KHz and now the ic callback is triggering , but i need the ic for fast signal like i mentioned in the beginning

 

> edit: I tried the timer input capture too, but still same effect, I used the HAL_TIM_IC_CaptureCallback , ...

Ozone_0-1762429236333.png

Don't you see the problem here ?
Are you not aware that "callbacks" are executed in interrupt context ?

I don't get it , what is the problem ? i'm still learning :)

While you running in interrupt context, especially of the very same interrupt, other one's will be blocked. 
Which can especially disastrous when when calling other time-consuming functions that in turn rely on interrupts.
I don't know this HAL UART functions work (I'm not a Cube/HAL user). But either interrupts or busy-wait until the transmission finished.

I don't know what you want to achieve here in your code example, probably only an indication that the EXTI interrupt was triggered.
Better set a flag or increment a counter, which you can access/evaluate from the main loop. That would suffice as a proof of concept. If it works once, it usually works always.
You always need to consider and check your MCU's time budget.