Page 1 of 1

Exceptions not firing even when explicitly hard-coded.

Posted: Thu Feb 20, 2020 9:32 pm
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?

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

Posted: Thu Feb 20, 2020 9:42 pm
by Giovanni
Hi,

You need to enable certain exception sources:

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

Giovanni