cancel
Showing results for 
Search instead for 
Did you mean: 

why I'm not able to get interrupt when Delay is being executed?

theashwanisingla
Associate

Hi all, I'm working on STM32L071CBTx. I'm trying to get external interrupt using GPIO pin in STOP MODE. I'm able to go to Stop Mode with RTC Enabled and also able to get the external Interrupt while in Stop Mode. But as per my requirement, I need a delay of 10 seconds before I go to stop mode. But if there is any interrupt in between those 10 seconds, my controller is not able to capture the interrupt. I have to wait for 10 seconds. I'm using HAL_Delay function for the delay. This delay function is using the RTC based Timer function with _NOP() command inside. I tried by deleting the _NOP() command(controllers do nothing while executing _NOP() as per my knowledge) but result is the same. Can anyone help/guide me regarding this issue?

2 REPLIES 2

Are you doing this in a callback or interrupt context? ​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

This is inside my main loop:

while( 1 )

{

if ( flag == 1)

{

flag = 0;

blink();

}

sleepon();

}

and GPIO initialization commands are:

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_RESET);

initStruct.Mode = GPIO_MODE_IT_RISING;

initStruct.Pull = GPIO_PULLDOWN;

initStruct.Speed = GPIO_SPEED_HIGH;

HW_GPIO_Init( GPIOA, GPIO_PIN_2, &initStruct );

HW_GPIO_SetIrq(GPIOA,GPIO_PIN_2,0,wakeup);

And sleepon function:

void sleepon(void)

{

HAL_Delay(12000);

HW_EnterStopMode();

}

void wakeup(void)

{

HW_ExitStopMode();

flag = 1;

}