Exceptions not firing even when explicitly hard-coded.

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

Moderator: RoccoMarco

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

Exceptions not firing even when explicitly hard-coded.

Post by mdh »

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: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

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

Post by Giovanni »

Hi,

You need to enable certain exception sources:

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

Giovanni
Post Reply