NV ram in teensy3.5 for non-volatile data storage

Arup

Member
I have made a project using Teensy 3.5 . Currently I have written the code in Arduino IDE.
It's working fantastic.
My issue is I have a counter value to be stored in battery backed ram of teensy 3.5.
I cant store in eeprom as the eeprom write cycle life will expire very soon.
I am using the Time library for RTC. It's working fine.
I found that the Teensy 3.5 has 32 bytes of battery backed up memory located at address 0x4003E000.
My counter value to be stored ranges from 0 to 2000.
Please tell me how to write code in Arduino ide to read and write the counter value to this battery backed memory address
Kindly send me the complete code to read and write the values.
I will insert this in my code .
I searched lots in google before writing to you but did not get any answer.
Awaiting prompt response !
 
Dear Sir,
Thank you so much for prompt response. Let me check and include the code . Then will update you about its functionality.
 
Keep in mind only 28 of the 32 bytes should be used, since the startup code on Teensy 3.x writes the last 4 bytes. Should not be an issue if using Defragster's example code which has a define to use only 7 of the 8 possible 32 bit words. I believe this is mentioned somewhere in the comments on that thread, but just want to repeat the cautionary message that the startup code sometimes overwrites the last 32 bit word, so only 28 of the 32 bytes are usable.

Usage by the startup code is only on Teensy 3.x. If using Teensy 4.0 or 4.1, which have 16 bytes, all 16 are usable. The startup code on Teensy 4.x does not write to this memory.
 
Most welcome. That code was written some time back - and was found as indicated with 'forum search' on the indicated value. The FORUM search is not ideal but - on occasion for such unique values like 0x4003E000 it will find prior posts. BING or that g00gle thing can do well searching the forum as well.

There are 8 DWORDS - but IIRC the 8th is used by PJRC to store the compile time for initial setting of the RTC clock value? >> CROSSPOST : CONFIRMED <<
// Accessing as 4 32 bit DWORDS of NVRAM backed data on 1062 MCU
// For T_3.x there are 7 DWORDS, the 8th is used by PJRC to track valid RTC clock
> this found in local code copy - ... wonder what else is different :)

Running the linked sketch as is should show it to work - and it includes SerMon menu items to reset the Teensy and advance the values outside the running +1.

Once that is seen to work hopefully minimizing the code for T_3.5 and excluding the T_4.x's 1062 code will provide an easy path to what is needed.
 
Dear Paul
Thanks a lot for the kind support ! i am in the process of testing the code. Will update soon.
 
Dear all members who responded to my query
Thank you so much ! the NV ram worked beautifully with a battery back up . Now we are able to store counts and retrieve the values at power up
 
Back
Top