cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX Race condition

osama2
Associate II
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
0 REPLIES 0