2014-01-11 04:49 AM
Hi all,
I want to detect a falling edge on external pinn let's say PD13 by hardware but without using the interrupt capability (using EXTI + NVIC).At first time I thought it is possible to do that using EXTI only by setting EXTI13 in event mode but I discovered that the interrupt pending bit is not set in event mode.I want my code to be like:while(1){ if(fallingedge == 1) { /* Do something */ } /* Application main processing */}Is there a trick to do that?Thanks in advance.2014-01-11 09:17 AM
From you code example you seem to want to detect it in software (despite the title), otherwise I don't understand what you are asking. Something like this would do it in software (for you to implement the specifics):
last_pin_state = pin_state = read_pin_state(); // initial state
while (1)
{
pin_state = read_pin_state();
if (!pin_state && last_pin_state)
{
// pin low but was high on last read so falling edge, do something
}
last_pin_state = pin_state;
// Application main processing
}
2014-01-13 03:22 AM
Hi
'' but I discovered that the interrupt pending bit is not set in event mode.'' The IRQ Pending bit will ONLY be set when the IRQ is enabled. I do not think there is any hardware in the STM32 that does what you want/think. As Trevor says - you pretty much polling the port bit. If you are worried about not catching the bit change - bear in mind the processor speed. You will be able to catch pulses down to 1us (microsecond) in SW polling.2014-01-13 03:51 AM
> The IRQ Pending bit will ONLY be set when the IRQ is enabled.
More specifically, the bit in EXTI_PR register will be set only if respective bit in EXTI_IMR register is set. This still does not imply that the interrupt will be invoked, as it still can stay disabled in the NVIC. > I do not think there is any hardware in the STM32 that does what you want/think. Oh c'mon. Besides using EXTI, the timer capture inputs, for example. JW