Greetings... I've been poring over the User's Guide (slau208), previous postings on E2E, and TI sample source long enough. I think its time for my own posting...
I'm working with an MSP430F5636 on a custom board. I'm working on getting RTC_B to preserve date and time when my main power source is turned off. The RTC is working for me but I'm having some troubles accessing registers in it because LOCKBAK keeps getting set even after I clear it.
I have a 3 V backup battery chip connected to VBAT on the MSP430. I'm powering the board with a 6 V external power supply through a DC/DC converter on the board that generates a 2.99 V Vcc that is the main power for the MSP430. I'm using a MSP-FET430UIF debugger that I have configured to provide no Vcc.
My start up code should look pretty familiar:
UCSCTL6 &= ~(XT1OFF); // XT1 On RTCCTL01 &= ~(RTCHOLD); // Start RTC calendar mode while(BAKCTL & LOCKBAK) // Unlock XT1 pins for operation BAKCTL &= ~(LOCKBAK); // Loop until XT1 & DCO stabilizes - In this case loop until XT1 and DCo settle do { UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG); // Clear XT2,XT1,DCO fault flags SFRIFG1 &= ~OFIFG; // Clear fault flags }while (SFRIFG1&OFIFG); // Test oscillator fault flag
What I'm finding is that when I run with the debugger connected, that LOCKBAK is cleared in my start up code and stays cleared. As a result I am able to read and write the RTC registers successfully. I've written a command in my firmware that allows me to see that LOCKBAK is cleared:
>get -y
SYSRSTIV: 0000
BAKCTL : c000
RTCCTL01: 3005
Now on the other hand, if I run with the debugger disconnected I can see that LOCKBAK doesn't stay cleared, (not to mention that I can't read or write the RTC registers):
>get -y
SYSRSTIV: 000e
BAKCTL : c001
RTCCTL01: 3001
I wrote another command that executes these lines of code to clear LOCKBAK:
while(BAKCTL & LOCKBAK) BAKCTL &= ~(LOCKBAK);
Even after executing the command to clear LOCKBAK I can look and see that it is set again.
Now for a couple quotes for the User's Guide:
from page 129:
LOCKBAK is always set to 1 by hardware after the core was powered down
either due to a complete power cycle of the main supply DVCC or due to LPMx.5
operation.
from page 126:
The LOCKBAK bit can be reset only when the supplies in the backup domain have settled. If for example
a discharged capacitor is connected to VBAT, this might take a couple of milliseconds after DVCC is
supplied. The recommended flow is to check if LOCKBAK reads 0 after having reset it by software.
Well I know I'm not power cycling the main supply Vcc and I'm not doing anything with low power modes. My VBAT is always connected to a battery so I would say the backup domain is always settled. (There is no capacitor connected to VBAT). So I'm trying to figure out why I can't clear LOCKBAK and keep it cleared. It works when my debugger is connected but not when I run stand alone. I've looked at my Vcc with a scope when I'm running stand alone to look for drops in the voltage that might cause this and I'm not seeing anything.
I'm not doing anything with the PMM. So SVSH and SVMH should be at their defaults and not do anything until the Vcc drops below ~1.64 V (from page 57 of the F5636 Data Sheet).
One could argue that having the debugger connected some how stabilizes my Vcc. But without it I don't see my Vcc changing enough that it causes a POR which would intern be setting LOCKBAK. Perhaps my problem is that I'm not understanding what causes LOCKBAK to set.
Also note, that due to the use of the while loop in the code when I clear it, that it is clearing (otherwise I'd get stuck in the while loop) but quickly after clearing it, it sets again.
Any thoughts, pointers or suggestions? What am I missing or not understanding?
Thanks...