MQX not starting when VBAT is not fully charged

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MQX not starting when VBAT is not fully charged

Jump to solution
1,562 Views
jesperevertsson
Contributor IV

Hi, we recently discovered a problem with our products. When we try to start them after they've been lying around without power for a while nothing happens at first and we have to break the power and restart them for it to work. We figured it had something to do with the VBAT being discharged and we are pretty sure that's the case. To force the error while being able to debug the code we disabled the capacitor to make sure the VBAT never gets charged. Then while stepping through the code we believe the problem arises in the function __pe_initialize_hardware() in the file bsp_cm.c. When we get to the line;

if ((RTC_CR & RTC_CR_OSCE_MASK) == 0u)

the code just stops executing, so I assume there is some problem with reading the RTC registers when the VBAT is not yet fully charged. Since the VBAT will be fully charged rather soon it would be better if the code could just reread the RTC registers until it gets the wanted the result but we are not sure how to accomplish this. Would it be possible to check the status of the VBAT before trying to read the RTC registers and just place that in a while loop to wait for the VBAT to become charged before continuing?

Tags (1)
0 Kudos
1 Solution
1,359 Views
cutworth
NXP Employee
NXP Employee

Hi Jesper,

Accessing RTC registers when VBAT power is not available will cause hard fault exception. I think the only way for your case is estimate worse case VBAT charge time and add delay in your code till VBAT power level is above 1.71V. 

Hao

View solution in original post

0 Kudos
7 Replies
1,359 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Jesper:

This seems a hardware issue. Yes, RTC is powered by VBAT, there maybe problem with reading the RTC registers when VBAT is not fully charged. I suggest you check your schematics for VBAT, please refer to the below picture. I assume you are using K65F180 chip.

pastedImage_2.png

Regards

Daniel

0 Kudos
1,359 Views
jesperevertsson
Contributor IV

Hello Daniel, we are using our custom hardware and we understand that the problem is caused by the hardware design. We also know ways we could fix it in the hardware, but we already have products that we've sold to customers and ideally we would be able to do a small adjustment in the bsp_cm.c file that prevents them from experiencing this bug.

If there is no way to get the status of the VBAT before trying to access the RTC registers would there be an easy way to just add a small time delay in the code before the RTC registers are accessed?

0 Kudos
1,357 Views
danielchen
NXP TechSupport
NXP TechSupport

What is the VBAT voltage when it's not fully charged, did you see hard fault when accessing RTC register when VBAT not charged?

Regards

Daniel

0 Kudos
1,357 Views
jesperevertsson
Contributor IV

Not sure, since it's a bit hard to get the timing right when meassuring that. All we can say for sure is that the cpu starts executing before the VBAT is charged enough to power the RTC. We managed to solve it in the hardware by making the VBAT charge up faster after the power to the hardware is enabled, but as I said this will not help in those cases where our customers have already received and started using the old hardware.

And what happened when trying to access the RTC register before the VBAT was fully charged I'm not 100 % sure. I was just stepping through the code and when I pressed "step over" on the line where the RTC register was read the execution stopped.

0 Kudos
1,360 Views
cutworth
NXP Employee
NXP Employee

Hi Jesper,

Accessing RTC registers when VBAT power is not available will cause hard fault exception. I think the only way for your case is estimate worse case VBAT charge time and add delay in your code till VBAT power level is above 1.71V. 

Hao

0 Kudos
1,357 Views
jesperevertsson
Contributor IV

Hello Hao, I was also thinking about always having a time delay as a way to work around this problem. I tried using the mqx _time_delay() call but since all the timer components are yet to be initialized that just stopped the program infinitely. Do you recommend just adding a big empty for loop or is there a better way to implement a time delay at this stage of the code execution?

0 Kudos
1,357 Views
cutworth
NXP Employee
NXP Employee

Hi Jesper,

I would suggest adding a big empty for loop. This is more simple.

Hao

0 Kudos