Which command to use to make a soft reset on K64F (KDS2 and KSDK110)?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Which command to use to make a soft reset on K64F (KDS2 and KSDK110)?

跳至解决方案
4,188 次查看
dafodil
Contributor III

Hi,

I need to be able to reset by software my application that works on K64F.

Do you know a command ?

Bernard

标记 (2)
0 项奖励
回复
1 解答
2,722 次查看
BlackNight
NXP Employee
NXP Employee

And just in case: attached the KinetisTools component which can do this both for Kinetis SDK and non-SDK projects

void KIN1_SoftwareReset(void)

{

  /* Generic way to request a reset from software for ARM Cortex */

  /* See https://community.freescale.com/thread/99740

     To write to this register, you must write 0x5FA to the VECTKEY field, otherwise the processor ignores the write.

     SYSRESETREQ will cause a system reset asynchronously, so need to wait afterwards.

   */

#if KIN1_IS_USING_KINETIS_SDK

  SCB->AIRCR = (0x5FA<<SCB_AIRCR_VECTKEY_Pos)|SCB_AIRCR_SYSRESETREQ_Msk;

#else

  SCB_AIRCR = SCB_AIRCR_VECTKEY(0x5FA) | SCB_AIRCR_SYSRESETREQ_MASK;

#endif

  for(;;) {

    /* wait until reset */

  }

}

Erich

在原帖中查看解决方案

0 项奖励
回复
7 回复数
2,720 次查看
BlackNight
NXP Employee
NXP Employee

Hi Bernard,

This is a generic way for ARM Cortex to perform a software reset:

void KIN1_SoftwareReset(void)

{

  /* generic way to request a reset from software for ARM Cortex */

  SCB_AIRCR = SCB_AIRCR_VECTKEY(0x5FA) | SCB_AIRCR_SYSRESETREQ_MASK;

  for(;;) {

    /* wait until reset */

  }

}

If you are using Processor Expert: that functionality/function is present in the 'KinetisTools' component:

pastedImage_7.png

available on SourceForge (see McuOnEclipse Releases on SourceForge | MCU on Eclipse).

Erich

2,720 次查看
dafodil
Contributor III

Hi Erich,

I got an error message, all macros are undeclared, where can I find the declaration? (my project is with KDSK110 and PE)

Bernard

0 项奖励
回复
2,720 次查看
BlackNight
NXP Employee
NXP Employee

Hi Bernard,

for the SDK, it is in core_cm4.h

and would be

SCB->AIRCR = (0x5FA<<SCB_AIRCR_VECTKEY_Pos)|SCB_AIRCR_SYSRESETREQ_Msk;

Erich

0 项奖励
回复
2,723 次查看
BlackNight
NXP Employee
NXP Employee

And just in case: attached the KinetisTools component which can do this both for Kinetis SDK and non-SDK projects

void KIN1_SoftwareReset(void)

{

  /* Generic way to request a reset from software for ARM Cortex */

  /* See https://community.freescale.com/thread/99740

     To write to this register, you must write 0x5FA to the VECTKEY field, otherwise the processor ignores the write.

     SYSRESETREQ will cause a system reset asynchronously, so need to wait afterwards.

   */

#if KIN1_IS_USING_KINETIS_SDK

  SCB->AIRCR = (0x5FA<<SCB_AIRCR_VECTKEY_Pos)|SCB_AIRCR_SYSRESETREQ_Msk;

#else

  SCB_AIRCR = SCB_AIRCR_VECTKEY(0x5FA) | SCB_AIRCR_SYSRESETREQ_MASK;

#endif

  for(;;) {

    /* wait until reset */

  }

}

Erich

0 项奖励
回复
2,720 次查看
dafodil
Contributor III

Hi Erich,

It's not working, maybe it's because I use MQX with RTCS.  The app stop, but don't restart.

I found a solution with WDOG from KSDK and the WDOG_DRV_ResetSystem();

0 项奖励
回复
2,721 次查看
BlackNight
NXP Employee
NXP Employee

Not sure why this does not work with MQX. It works fine for me with the Kinetis SDK and FreeRTOS.

0 项奖励
回复
2,722 次查看
dafodil
Contributor III

In fact, the use of kinetis tools make some instability inside my project after adding ksdk component.

I will try again with the new KDS3!

For now, I reboot the app with timeout watchdog. It's not really the best solution, but it works.

0 项奖励
回复