After the board is powered down and powered on, program will not run properly without redownload pr


After the board is powered down and powered on, program will not run properly without redownload pr

417 次查看
Contributor I

Application scenario: The S912ZVM chip drives the BLDC motor with Hall, and the duty cycle of PWM generator corresponds to the speed of the motor.  

Symptom: Each time you power on the board, download the program again. Otherwise, the board cannot start normally.  (After the board is powered down and then powered on, the program will not run properly without redownloading the program.)  

To summarize: the above is in debug mode to observe the changes after the power failure, everything is normal at the beginning.  After the power failure, it prompts CONNECT, but the Hall interrupt and PWM input capture interrupt cannot be jumped in (Hall sector of the rotating motor does not change, and PWM duty ratio cannot be calculated), because the motor speed is corresponding to a specific duty ratio, so the motor does not run.  

0 项奖励
1 回复

412 次查看
NXP TechSupport
NXP TechSupport


your description leads me to idea of setup feature of some bits.

Write: Once in normal, anytime in special mode

If we change value of such a bit in debug mode more than once then nothing happens and the MCU will perform function on the basis of the bit current bit setup. However, if we are in normal mode then the only first setup of the bit is accepted and al other changes are ignored.

We have met a lot of times that user uses some general setup functions or some project wizard and then you decide to set some registers yourself. Project wizard sets its own values and your ones are then ignored or vice versa.

Next thing you should check is interrupt flag clearing. Some bit is not cleared and the MCU is always in some interrupt with higher priority. Usually, flags are cleared by writing 1 to corresponding bit.

However, following approach is incorrect.

register_bit6 = 1; 

Also incorrect is

register |= 0x40;

Correct approach is register = 0x40; // =0B01000000

More info in

But, I always suggest to check approach for correct clearing of given bit because some interrupt flags can be placed inside standard register which contains also setup bits. In this case the approach is to work directly with given bit to do not influence other bits.

Best regards,


0 项奖励