MCF52259 Reset

cancel
Showing results for 
Search instead for 
Did you mean: 

MCF52259 Reset

Jump to solution
292 Views
salman83
Contributor II

Hi,

 

I have two applications on my MCF52259 controller. One is user app and  the other is bootloader. When I get a command to update the user app, I need to switch to bootloader. In order to do that, I can do the software reset. But there is one problem, I do not want to lose the RAM data and also I want to shutdown all peripherals as well.

 

Is it possible to do it?

 

Regards.

Labels (1)
Tags (2)
0 Kudos
1 Solution
106 Views
TomE
Specialist I

> I do not want to lose the RAM data

I assume you mean the internal SRAM and not some other memory attached to the chip. I can't find anything in the manual that says that the SRAM contents don't survive a CPU Reset. Have you found otherwise?

If your problem is that your Bootstrap code clears all the RAM when it starts, then that's a software problem. Change it so it doesn't.. When your Bootstrap starts it should check "11.5.2 Reset Status Register (RSR)". If the reason was a SOFT reset it should check to see if there's a signature/command and data left at a fixed location in RAM to burn to program FLASH, and then burn it. For any other type of Reset (or a SOFT one without the right data left in RAM) it should start normally.

> I want to shutdown all peripherals as well.

If you don't want to perform a reset, then just write code that reverses all the actions of the code that started the peripherals. Disable CPU interrupts, write all the interrupt controller registers back to their documented reset states, return all peripheral registers to default states (after shutting down the "smart ones" like Ethernet, DMA and so on). Good luck with the Watchdogs, they can be tricky.

If your code is well written with separate code modules for each peripheral, then you can have both "open" and "close" functions written for all of them.

Or as Michael suggested, update the App from a small part of the App copied to RAM and run from there.

Tom

View solution in original post

0 Kudos
3 Replies
106 Views
Monica
Senior Contributor III

Hello Salman,

did any of that help? Please keep us posted! :smileywink:

Regards,

Monica

0 Kudos
107 Views
TomE
Specialist I

> I do not want to lose the RAM data

I assume you mean the internal SRAM and not some other memory attached to the chip. I can't find anything in the manual that says that the SRAM contents don't survive a CPU Reset. Have you found otherwise?

If your problem is that your Bootstrap code clears all the RAM when it starts, then that's a software problem. Change it so it doesn't.. When your Bootstrap starts it should check "11.5.2 Reset Status Register (RSR)". If the reason was a SOFT reset it should check to see if there's a signature/command and data left at a fixed location in RAM to burn to program FLASH, and then burn it. For any other type of Reset (or a SOFT one without the right data left in RAM) it should start normally.

> I want to shutdown all peripherals as well.

If you don't want to perform a reset, then just write code that reverses all the actions of the code that started the peripherals. Disable CPU interrupts, write all the interrupt controller registers back to their documented reset states, return all peripheral registers to default states (after shutting down the "smart ones" like Ethernet, DMA and so on). Good luck with the Watchdogs, they can be tricky.

If your code is well written with separate code modules for each peripheral, then you can have both "open" and "close" functions written for all of them.

Or as Michael suggested, update the App from a small part of the App copied to RAM and run from there.

Tom

View solution in original post

0 Kudos
106 Views
michaelzhangca
Contributor II

(1)If you have enough RAM, you can download your user app to an unused memory in RAM, this address should be fixed or write to an RAM address for further using.

(2)write a small executable code that will copy the data start from the above address to flash, put the generated executable code in somewhere in flash, make sure change the lcf file to make the code run in RAM, not in flash.

(3)In your user app, after you saved all you new user app to RAM, copy the code generated in (2) into RAM, and run the code.

Make sure the memory you used in (1) and (2) not overlap your user app RAM.

0 Kudos