Custom Handlers; Figure 38. Asking For Handler Code Generation - STMicroelectronics STM32 Application Note

Microcontroller debug toolbox
Hide thumbs Also See for STM32:
Table of Contents

Advertisement

Exception handling
6.2

Custom Handlers

One way to generate templates of Handler functions is to use STM32CubeMX.
In Configuration -> NVIC Configuration -> Code Generation, use Generate IRQ handler
tick boxes as shown in
When Non maskable interrupt and Hard fault interrupt are selected, the following code is
generated:
void NMI_Handler(void)
{
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
/* USER CODE END NonMaskableInt_IRQn 0 */
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
/* USER CODE END NonMaskableInt_IRQn 1 */
}
/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */
while (1)
{
}
/* USER CODE BEGIN HardFault_IRQn 1 */
/* USER CODE END HardFault_IRQn 1 */
}
This simple declaration overriding the default weak function,removes ambiguity and clarifies
the call stack.
58/118
Figure
38.

Figure 38. Asking for Handler code generation

AN4989 Rev 3
AN4989

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the STM32 and is the answer not in the manual?

Table of Contents

Save PDF