my mcu is "mk10dx256",How to use 32-byte VBAT register.

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

my mcu is "mk10dx256",How to use 32-byte VBAT register.

1,354 Views
jikehe
Contributor II

My mcu is "mk10dx256", The chip is powered down except for the VBAT supply. The RTC and the 32-byte VBAT register file for customer-critical data remain powered.

How to use 32-byte VBAT register.

Labels (1)
6 Replies

823 Views
cutworth
NXP Employee
NXP Employee

The VBAT register file is located at 0x4003_E000, so in your code, when MCU VDD powered, you can write directly to this address to store data. After MCU power off, it keeps data with VBAT powered.

The system register file located at 0x4004_1000 is powered by MCU VDD and retains its data even at VLLS1 mode.

0 Kudos

823 Views
jikehe
Contributor II

How to write data at 0x4003_E000

0 Kudos

823 Views
egoodii
Senior Contributor III

The exact syntax to place a variable at an absolute address is compiler-specific, BUT you might find the header-file for your uC already contains a 'hook' for you.  The MK20D10.h I use in IAR has the macro RFVBAT_REG(index) pre-defined to point to this hardware as 8 32bit locations with:

#define RFVBAT_BASE_PTR                          ((RFVBAT_MemMapPtr)0x4003E000u)

and a matching RFSYS_REG(index) pointed at:

#define RFSYS_BASE_PTR                           ((RFSYS_MemMapPtr)0x40041000u)

Just make sure the 'clocks' are turned on, as with any peripheral register set!  That being said, it looks like 'current' Kinetis has the system regfile permanently enabled (SIM_SCGC5 D1=1), and the RTC clock (SIM_SCGC6) is NOT(?) required to access the VBAT register file, but IS required to get RTC_SR 'TIF' which might tell you if the VBAT registers are also invalid.

0 Kudos

823 Views
big_steve
Contributor III

Hi.

I set all bits in SIM_SCGC5 register to 1 but i can't still execute read or write operation on VBAT register file. The program always breaks at write operation. What could be the problem? What needs to be done to get VBAT register file to work?

I would like to store a LCD calibration structure to VBAT registers mentioned in this topic: Re: Avoid the calibration screen on each tensioning?

My configuration is:
eGui

MQX 4.0
CodeWarrior 10.3
TWR-K40X256, TWR-LCD and TWR-SER

Thank you for your answer.

0 Kudos

823 Views
egoodii
Senior Contributor III

You aren't showing me much of what you tried, exactly.  For my 'test case' on an MK20, I simply placed this source line (w/o any CLK enables):

    RFVBAT_REG(0) = 0x12345678;

which nets these object-file lines:

       0x40fc: 0x481c         LDR.N     R0, ??DataTable4_1      ; RFVBAT_RFVBAT_REG0

       0x40fe: 0x491d         LDR.N     R1, ??DataTable4_2      ; 0x12345678 (305419896)

       0x4100: 0x6001         STR       R1, [R0]

which nets this result in the debugger 'memory' window, starting at 0x4003e000

78 56 34 12 00 00 00 00 00 00 00 00 00 00 00 00

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

which stays until I pull the battery.

Maybe we need to consider some more 'basic' questions, like is your Vbat supply pin tied to a battery & VCC (J12 to 2&3)?

0 Kudos

823 Views
big_steve
Contributor III

Yes, the J12 jumper is at 2&3 position, so the Vbat supply pin is tied to battery and VCC.
The Disassembly shows me this for your source line:

     00009ae4:   movw r1,#0x5678

     00009ae8:   movt r1,#0x1234

     00009aec:   movw r0,#0xe000

     00009af0:   movt r0,#0x4003

     00009af4:   str r1,[r0,#0]

When i try to view the VBAT register files in debug mode with CodeWarrior, it comes always an alert "The debugger lost communication on connection..."
If this source line is executed in debug mode in CodeWarrior, CodeWarrior stops responding. Then i need to kill the program or in a while apears above mentioned alert.


I am going to try it with an empty MQX project to see what happens.

EDIT: Problem solved. I had to enable RTC Access Control bit in SIM_SCGC6. Fistly it doesn't work, but after a second try it worked.
Thank you.