Exceptions not firing even when explicitly hard-coded.

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: barthess, RoccoMarco

mdh
Posts: 1
Joined: Thu Feb 20, 2020 6:45 pm

Exceptions not firing even when explicitly hard-coded.

Postby mdh » Thu Feb 20, 2020 9:32 pm

Hey all! I'm a long-time lurker, first-time poster. I'm working on a project with the STM32F4, working from 17.6 branch (upgrading soon). The problem I'm encountering is that I'm trying to implement custom exception handlers, and best as I can tell, I've done so correctly, but even if I explicitly put the system in a state that should trigger an exception, they don't fire. I've done the following:

  1. Overwrite the handlers for UsageFault and _unhandled_exception via the `CH_IRQ_HANDLER` API
  2. Follow the 'regular interrupt handlers' instructions per this page.
  3. Call `chSysEnable() in my main() function before hitting a while(true) block`

Code in main() to replicate my problem would look more or less like this:

Code: Select all

  volatile uint16_t divisor  = 0;
  volatile uint16_t dividend = 0;
  volatile uint16_t result   = 0;
  chSysEnable();

  while (true)
  {
    chThdSleepMilliseconds(10000);

    result = dividend++ / divisor;
  }


AFAIK, this should cause a UsageFault for division by zero, but I never see the exception happen. Is there some configuration I'm missing?

User avatar
Giovanni
Site Admin
Posts: 12749
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 696 times
Been thanked: 573 times
Contact:

Re: Exceptions not firing even when explicitly hard-coded.

Postby Giovanni » Thu Feb 20, 2020 9:42 pm

Hi,

You need to enable certain exception sources:

https://developer.arm.com/docs/dui0553/ ... l-register

Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 3 guests