EasyManuals Logo

STMicroelectronics STM32 User Manual

STMicroelectronics STM32
118 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #60 background imageLoading...
Page #60 background image
Exception handling AN4989
60/118 AN4989 Rev 3
Figure 39. Keil
®
Access to Show Caller Code in Contextual menu
6.3 Trapping div/0 exception
Most often, code execution causing a division by zero are difficult to investigate:
Nothing is neither triggered nor trapped.
Erroneous returned value generates an unexpected and unpredictable behavior that is
very difficult to analyze.
This chapter gives several tips in order to properly trap div/0 exceptions.
6.3.1 Cortex
®
-M0/M0+ case
For targets that do not support hardware division instructions (SDIV/UDIV), integer division-
by-zero errors can be trapped and identified by means of the appropriate C library helper
functions:
__aeabi_idiv0()
When integer division by zero is detected, a branch to __aeabi_idiv0() is made. A
breakpoint placed on __aeabi_idiv0() allow to trap the division by zero.
To ease the breakpoint application, override the default function:
void __aeabi_idiv0()
{
#ifdef DEBUG
__BKPT(0);
#endif
}
This way, and depending on IDE, the call stack or registers can be examined and the
offending line in the source code can be rapidly found.
To go further refer to section 7.7 of Arm
®
Compiler Software Development Guide.

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

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

STMicroelectronics STM32 Specifications

General IconGeneral
BrandSTMicroelectronics
ModelSTM32
CategoryMicrocontrollers
LanguageEnglish

Related product manuals