Skip to main content
osama2
Associate II
October 18, 2015
Question

CubeMX Race condition

  • October 18, 2015
  • 0 replies
  • 397 views
Posted on October 19, 2015 at 00:11

The generated code initializes all peripherals and enables interrupts.

The application code's first hook is after peripheral initialization.

How do I ensure that no interrupts before all high level peripherals are ready?

Example:

In the RTC IRQ handler I read data from a sensor.

The sensor needs an initialization sequence before being operational.

Too bad that the RTC interrupt is enabled *before* I can initialize the sensor.

RTC-Interrupt orrurs, sensor not yet ready, crash.

__disable_irq() / __enable_irq() is not an option because it blocks SysTick which the initialization code relies on.

Off Course I can do ''IfSensorIsEnabled()'' in the RTC IRQ handler but why should I?

IMHO this is another case of bad embedded software architecture in CubeMX.

/Osama
    This topic has been closed for replies.