2023-08-19 04:04 AM - edited 2023-08-19 04:06 AM
Hi
I have pin PA6 setup to interupt on high and low levels. I have done the following:
GPIOA->MODER &= ~GPIO_MODER_MODE6; //PA6 as input
SYSCFG->EXTICR[1] &= ~SYSCFG_EXTICR2_EXTI6; //PA6
EXTI->RTSR1 |= EXTI_RTSR1_RT6; //enable rising edge
EXTI->FTSR1 |= EXTI_FTSR1_FT6; //enable falling edge...
EXTI->IMR1 |= EXTI_IMR1_IM6;
NVIC_SetPriority(EXTI9_5_IRQn,1);
NVIC_EnableIRQ(EXTI9_5_IRQn);
In the interupt routine, I simply set a variable when interupt is because of low/high (just for testing).
volatile char ExtLow=0;
volatile char ExtHigh=0;
void EXTI9_5_IRQHandler(void)
{
if((EXTI->PR1 & EXTI_PR1_PIF6)==EXTI_PR1_PIF6)
{
EXTI->PR1 |= EXTI_PR1_PIF6;
if(! (GPIOA->IDR & GPIO_ODR_OD6))
ExtLow=1;
else
ExtHigh=1;
}
}
The pulse with is for about 100ms, not fast (processor at 80MHz). If I put a break point on ExtLow=1; line, it never breaks here. But the interupt does get called, which I have checked. Even when I simply set for low level interupt (not high), it doesnt break, and again, the interupt does get called. Anyone any idea how I can check if its a low edge or high edge that caused the interupt?
Many Thanks
Scott
2023-08-22 10:05 AM
I thought you meant generate a pulse with the same pin, and also detect an input interupt by using the same pin. But I see what you mean, and yes i can generate a pulse with the same pin when setup as an output
2023-08-22 01:35 PM
> I thought you meant generate a pulse with the same pin, and also detect an input interupt by using the same pin.
Yes, he meant exactly that. EXTI is not bound to pin to be set to input in GPIO.
JW