Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Non-volatile registers.

Status
Not open for further replies.

alphadog

Banned
Hello.
I have CC2430 MCU, but i assume that my question is more general.

I'd like to save some data in non-volatile registers.
What in datasheet should i look for in order to find General Purpose registers that keep their value after power-off.

Thanks.
 
Last edited:
I have not seen any microcontrollers with nonvolatile registers.

As suggested earlier save the info you want in flash or other EEPROM and load it as needed when your program starts.

Are you working with ZigBee ?
 
Last edited:
Thanks for the answer.
Yes i work with Zigbee.
I have a problem and maybe you can help me out with this.
I need to poll data from external chip (that measures power consumption) every 30 seconds (Because i dont want for example to miss an activation of a kettle).
I'm afraid to write to MCU's flash in such high rate because it wouldnt last so long in this case.

What can i do then to overcome this problem?
 
You're wanting something that keeps its value with no power. By definition, "non volitile" memory. Check your data sheets on the processor you use and see if it has flash momory that can be written to by your program. This is non volitile. I know PICS use internal flash for executable code, but not sure if you can save (write) data to flash from your executing program. I do this but I am using Renesas processors.

Looks like you might want battery backup ram.


Then again writing a few bytes to a 1 gig flash at incrementing addresses once every 30 seconds would be *quite* a time span and would provide a convienient history as well.
 
Last edited:
There are tricks that you can play.

About the best it to detect the power to the uC dropping and save the data as the power goes down.

If the saved value does not need to be exact you update the saved value only when it is too different then the actual value.

Depends on the nature of the data.

3v0
 
There are tricks that you can play.

About the best it to detect the power to the uC dropping and save the data as the power goes down.

If the saved value does not need to be exact you update the saved value only when it is too different then the actual value.

Depends on the nature of the data.

3v0

Thank you.
Say that i have the option to detect the power dropping, how do i know that I have enough time to write to flash before the UC stop functioning?

Flash write takes 20uSec, but But i need to write about ~30 words (flash is word-addressable for writing) before power-down.

What do you think?
 
I am a software guy so this is on the fringe of what I know.

How much time you have depends on your system including the PS.

The CC2430 requires 2.0V-3.6V. That only leaves a volt and a half to play with. You could monitor the input voltage to the regulator, and have more time prior to VDD going too low for the chip to function.

I am thinking the first thing you would want to do is turn off the TX RX and any other hardware that uses a lot of current.

A capacitor would slow the voltage drop.

There are two ways you could detect the voltage drop. One would be to use an external comparator and have it alert the process via an interrupt line. Or use the onboard ADC to measure the voltage.

Once you have either of these you can output pulses after detection and count them to see how long between detection and failure.

3v0
 
Last edited:
Are you worried about saving data from an external device into non volitile memory or saving data during a power failure?
 
I'm worried about saving data into non volatile memory every 30 sec, because it will get wasted after short time.

3V0.
I can try it, but it seems to unreasonable that in such a short time i'll be able to turn off all power consumers GPIOs and peripherals and write to flash.
It seems unacheivable.
 
Last edited:
I'm worried about saving data into non volatile memory every 30 sec, because it will get wasted after short time.

3V0.
I can try it, but it seems to unreasonable that in such a short time i'll be able to turn off all power consumers GPIOs and peripherals and write to flash.
It seems unacheivable.

The rate at which the power drops is slow compared to how fast the uC runs. You only need 600uS to write your data. I am not sure what devices it pays to turn off. You have to check the datasheet and experiment with that.
 
Thank you, i'll give it a shot.

Could you tell me please how do i read from flash?
They explain there how to write, but how do i read a specific address from flash memory?
I write in C and dont know what command to use.
 
Last edited:
Declare a constant array and make sure the compiler puts it into flash.

const unsigned int16 myData[30];

depending on the compiler you may have to add a memory type qualifier

rom const unsigned int16 myData[30];

if you write to address myData, the written data should be in the array. mData and &myData[0] should be the same.
 
Thanks for the effort!

You mean that if i want to write to lets say 1KB of flash, then i need to allocate an array of 1KB size and have it mapped to the flash 1KB memory space that i want to write to?

Could you please explain about "make sure the compiler puts it into flash"?
 
Thanks for the effort!

You mean that if i want to write to lets say 1KB of flash, then i need to allocate an array of 1KB size and have it mapped to the flash 1KB memory space that i want to write to?

Could you please explain about "make sure the compiler puts it into flash"?

I do not know you compiler or chip, but I think you have it. If you use the const modifer there is a very good chance the array will be located in flash (this is compiler dependant). It is easier to let the compiler/linker figure out where to place the array. You could use the linker to setup a specific location in flash but do not fuss with that yet.

If you provide a link to you compiler docs I will take a look and see if I can find more info.
 
Some need it declared as "far" also. Just might ought to check.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top