We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Guys - I am new to this micro and this tool set, and I need some help. I need to set a flag and then perform a CPU software reset (due to another problem). But I need to have a byte that survives the software reset and does not get cleared. If I define an XDATA byte, the STARTUP code will (I think) zap it before I can see it.
How can I write an XDATA byte (or any other byte for that matter) that will survive a software reset (not a power down, just a reset)?
Can anyone help?
Thanks in advance!
Chris
You did not specify a chip. But the Memory is cleared in startup.a51. Copy it from the compiler directory to your project folder. Then edit it as needed, the compiler will use the one in your folder.
Sorry, you are correct. I am using the 8051F320 device, and uVision4.
I went into STARTUP and changed the code to not clear the XRAM and I think that did it. I was wondering if there is any way to refer to an XRAM location without the compiler knowing about it and clearing it, but I guess not. I will have to make an exclusion for that byte in STARTUP so the rest gets cleared.
I am fighting a USB problem where the 'F320 gets stuck and stops communicating. I figured out how to detect that condition and reset the device. However, after the reset the device goes away and never enumerates again. (I think it is the old USB problem of devices that go away while in use.) Anyway, I found that if I reset the device again then it magically enumerates again, so I was trying to make the code reset it and then reset it again.
Thanks for your help, Neil!
Yes you can declare a variable at an address look up @ in the manual. You can get a pointer an point at anything you want.
I would allow startup to clear all the RAM except you byte. Put it at the end of RAM for convenience. Not clearing the RAM may give you random problems, if things expect the RAM to be cleared. Does you chip have a reset reason indicator? If so you may want to use that i the clear / do not clear decision.
Neil -
What I did was to declare an XDATA byte:
UCHAR xdata NeedsReset _at_ 0x3FFF;
And then I went into STARTUP.A51 and altered it to not clear the XDATA.
That seemed to work! Thanks!
You can have the startup file clear XDATA - just modify the amount of data that gets cleared. For example reserving the last 16 bytes for information that should survive a reboot (but obviously not a power loss)
(but obviously not a power loss)
Unless your XDATA is non-volatile (e.g., battery backed).
I am fighting a USB problem where the 'F320 gets stuck and stops communicating. I figured out how to detect that condition and reset the device. However, after the reset the device goes away and never enumerates again. (I think it is the old USB problem of devices that go away while in use.) Anyway, I found that if I reset the device again then it magically enumerates again, so I was trying to make the code reset it and then reset it again. you will, probab;y, be better off posting at the SILabs forum www.cygnal.org/.../Ultimate.cgi
Erik
Understood, but my question was about using 'C' and variables that would get past resets. Thanks to all who helped!
just a helpful hint