cancel
Showing results for 
Search instead for 
Did you mean: 

Why SysTick_Handler won't execute within an EXTI_IRQHandler?

dbilancione
Associate II
Posted on February 04, 2015 at 01:24

Hi there.

I can't get my head around this and was hoping someone could help ... despite having set a higher priority to the SysTick irq, it doesn't seem to decrement an integer variable when called from an ira triggered by a push button. here some code ...


/**

******************************************************************************

* @file src/stm32f4xx_it.c

* @author

* @version V1.0.0

* @date 25-January-2015

* @brief Main Interrupt Service Routines.

* This file provides template for all exceptions handler and 

* peripherals interrupt service routine.

******************************************************************************

*/ 


/* Includes ------------------------------------------------------------------*/

#include ''main.h''



/** @addtogroup

* @{

*/


/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

__IO uint32_t TimingDelay;


/* Private function prototypes -----------------------------------------------*/

static void Delay_ms(uint32_t ms);


/* Private functions ---------------------------------------------------------*/


/******************************************************************************/

/* Cortex-M4 Processor Exceptions Handlers */

/******************************************************************************/


/**

* @brief NMI_Handler

* This function handles NMI exception.

* @param None

* @retval None

*/

void NMI_Handler(void)

{

}


/**

* @brief HardFault_Handler

* This function handles Hard Fault exception.

* @param None

* @retval None

*/

void HardFault_Handler(void)

{

/* Go to infinite loop when Hard Fault exception occurs */

while (1)

{

}

}


/**

* @brief MemManage_Handler

* This function handles Memory Manage exception.

* @param None

* @retval None

*/

void MemManage_Handler(void)

{

/* Go to infinite loop when Memory Manage exception occurs */

while (1)

{

}

}


/**

* @brief BusFault_Handler

* This function handles Bus Fault exception.

* @param None

* @retval None

*/

void BusFault_Handler(void)

{

/* Go to infinite loop when Bus Fault exception occurs */

while (1)

{

}

}


/**

* @brief UsageFault_Handler

* This function handles Usage Fault exception.

* @param None

* @retval None

*/

void UsageFault_Handler(void)

{

/* Go to infinite loop when Usage Fault exception occurs */

while (1)

{

}

}


/**

* @brief SVC_Handler

* This function handles SVCall exception.

* @param None

* @retval None

*/

void SVC_Handler(void)

{

}


/**

* @brief DebugMon_Handler

* This function handles Debug Monitor exception.

* @param None

* @retval None

*/

void DebugMon_Handler(void)

{

}


/**

* @brief PendSV_Handler

* This function handles PendSVC exception.

* @param None

* @retval None

*/

void PendSV_Handler(void)

{

}


/**

* @brief SysTick_Handler

* This function handles SysTick Handler.

* @param None

* @retval None

*/

void SysTick_Handler(void)

{

TimingDelay_Decrement();

}


/******************************************************************************/

/* STM32F4xx Peripherals Interrupt Handlers */

/******************************************************************************/


/**

* @brief USARTx_IRQHandler

* This function handles USARTx global interrupt request.

* @param None

* @retval None

*/

void USARTx_IRQHandler(void)

{

}


/******************************************************************************/

/* STM32F4xx Peripherals Interrupt Handlers */

/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */

/* available peripheral interrupt handler's name please refer to the startup */

/* file (startup_stm32f4xx.c). */

/******************************************************************************/


/**

* @brief EXTI0_IRQHandler

* This function handles External line 0 interrupt request.

* @param None

* @retval None

*/

void EXTI0_IRQHandler(void) /* WU button */

{

if(EXTI_GetITStatus(EXTI_Line0) != RESET)

{

STM_LEDToggle(LED4);

Delay_ms(20);

STM_LEDToggle(LED4);

Delay_ms(20);



/* Clear the EXTI line 0 pending bit */

EXTI_ClearITPendingBit(EXTI_Line0);

}

}


/**

* @brief EXTI15_10_IRQHandler

* This function handles External line .15 interrupt requests.

* @param None

* @retval None

*/

void EXTI15_10_IRQHandler(void) /* U button */

{

if(EXTI_GetITStatus(EXTI_Line10) != RESET)

{

/* Toggle LED3 */

STM_LEDToggle(LED3);

Delay_ms(20);



/* Clear the EXTI line 10 pending bit */

EXTI_ClearITPendingBit(EXTI_Line10);

}

}


/**

* @brief This function handles PPP interrupt request.

* @param None

* @retval None

*/

/*void PPP_IRQHandler(void)

{

}*/


/**

* @brief Inserts a delay time.

* @param ms: specifies the delay length in milliseconds

* @retval None

*/

static void Delay_ms(uint32_t ms)

{

TimingDelay = ms;


while(TimingDelay != 0);

}


/**

* @brief Decrements the TimingDelay variable.

* @param None

* @retval None

*/

void TimingDelay_Decrement(void)

{

if (TimingDelay != 0x00)

{

TimingDelay--;

}

}


/**

* @}

*/ 


/***************************************************************END OF FILE****/

thank you! #systick_handler #exti_irqhandler
1 REPLY 1
Posted on February 04, 2015 at 01:35

Yet you don't show any code related to the configuration or priority, or specifically Preemption.

It's a very bad plan to spin on an interrupt dependent value in an interrupt. Can you not use a free running timer, or DWT_CYCCNT, or something more appropriate.

Priority controls what gets done next when the current interrupt exits (tail chains), Preemption determines if the interrupt gets interrupted.

SysTick is usually configured as the least important, and is a System Handler, not an NVIC interrupt, a subtlety that's important to understand when setting it's Priority/Preemption level.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..