Software Reset in Kinetis Family

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

Software Reset in Kinetis Family

2,524 Views
elisamejia
Contributor III

Hi everyone,

I have a program using Kinetis microcontrollers and I need to reset all the data in the microprocessor every time it is started. How can this be performed by software?

Thanks!

0 Kudos
7 Replies

1,173 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi,

you can use this function to reset MCU by software:

//-----------------------------------------------------------------------------

// FUNCTION:    Cpu_SystemReset

// SCOPE:       Bootloader application system function 

// DESCRIPTION: Force a system reset

//-----------------------------------------------------------------------------

void Boot_Cpu_SystemReset(void)

{

  /* SCB_AIRCR: VECTKEY=0x05FA,SYSRESETREQ=1 */

  SCB_AIRCR = (uint32_t)((SCB_AIRCR & (uint32_t)~(uint32_t)(

               SCB_AIRCR_VECTKEY(0xFA05)

              )) | (uint32_t)(

               SCB_AIRCR_VECTKEY(0x05FA) |

               SCB_AIRCR_SYSRESETREQ_MASK

              ));                      /* Request system reset */

  while(1) {                           /* Wait until reset */

  }

this part of code is used in demo:

Kinetis Bootloader to Update Multiple Devices in a Network - for Cortex-M0+

can this help you?


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,173 Views
elisamejia
Contributor III

Hi ZhangJennie,

Your code seems to be working. However, this is not what I'm looking for. I need someway to reset the microcontroller, in this case a K70, every time it is plugged in to a voltage supply. Then, I will need to set some parameters that will restart my microcontroller only once.

Do you know how can I do this?

Regards,

Elisa

0 Kudos

1,173 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Elisa Mejia:

When you connect the K70 to the voltage supply, that is by itself a reset called POR (Power On Reset), so no special software needed. To cause a software reset once the MCU is running, the typical procedure is as explained by Jennie.

Please explain your goal or requirement with more details so we can offer some feedback or advice.

Regards!

Jorge Gonzalez

0 Kudos

1,173 Views
elisamejia
Contributor III

Hi Jorge,

I have a K70 tower module that is controlling a TWR-LCD-RGB. Whenever I turn it on, the LCD fails on showing the interface and I need to reset the K70 manually using the reset button located in the board. However, the board is to be located in a box and isolated, so I need it to start displaying in the LCD every time I connect it without the need of manually resetting it.

I tried what Jennie recommended, and it does work whenever I call the function once. However, I don't know how to apply it in order to avoid my issue here.

Regards,

Elisa

0 Kudos

1,173 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hi Elisa:

In that case you can use software reset with the condition of only resetting if the K70 MCU comes from POR reset, by reading the register RCM_SRS0, like this:

// If latest reset was caused by POR

if(RCM_SRS0 & RCM_SRS0_POR_MASK)

{

     /* SCB_AIRCR: VECTKEY=0x05FA,SYSRESETREQ=1 */

     SCB_AIRCR = (uint32_t)((SCB_AIRCR & (uint32_t)~(uint32_t)(SCB_AIRCR_VECTKEY(0xFA05))) | (uint32_t)(SCB_AIRCR_VECTKEY(0x05FA) | SCB_AIRCR_SYSRESETREQ_MASK));

     while(1){}

}

So the K70 resets only once after connecting to the supply.

Of course this is a workaround, but it may be worth debugging the actual issue of the system not working after POR.

Regards!

Jorge Gonzalez

0 Kudos

1,173 Views
elisamejia
Contributor III

Hi Jorge,

It still does not work., but now it does reset when I want it to. The problem now I think is related to the TWR-LCD-RGB.

I am displaying some signals in the TWR-LCD-RGB. When I turn the Tower System ON the LCD remains displaying what it was displaying when it was turned off, and I need to push the reset button so it starts displaying from scratch again.

I really don´t know why is this happening or which is the difference between the software reset and the hardware reset.

Elisa

0 Kudos

1,173 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Normally, your problem should not happen when using TWR-LCD-RGB board, I suggest you test the system with an official demo code so that we can know if the problem is on your SW design.

regarding difference between SW and HW reset, HW reset pull the electrical level of the cpu. hard reset certainly means that the whole CPU chip and all its peripherals are reset.

SW reset, the content of RAM/registers may be maintained through a soft reset, but not through a hard reset, with above code we provided, it branchs to the reset vector. the soft reset hits some inside layer possibly not the whole chip.


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos