Keil Logo Arm Logo

ARM: SOFTWARE RESET IN C

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Tobias Mueller
Posted
13-Jun-2008 20:11 GMT
Toolset
ARM
New! ARM: SOFTWARE RESET IN C

How can I put a software reset into my source code?
I'm using the NXP LPC2368.

I only found a solution for the C51.
http://www.keil.com/support/docs/307.htm

Read-Only
Author
Per Westermark
Posted
13-Jun-2008 22:20 GMT
Toolset
ARM
New! RE: ARM: SOFTWARE RESET IN C

To get a software reset, activate the watchdog timer and then busy-loop until the watchdog resets the processor.

Read-Only
Author
Tobias Mueller
Posted
14-Jun-2008 11:09 GMT
Toolset
ARM
New! RE: ARM: SOFTWARE RESET IN C

Thanks for your help. I'm sorry, but do you know how I could activate the watchdog timer?

Do you mean for example "while(1);" as busy-loop?

Read-Only
Author
Tamir Michael
Posted
14-Jun-2008 16:02 GMT
Toolset
ARM
New! RE: ARM: SOFTWARE RESET IN C

if you are using ST's library, you can get away with something like this:

  SCU_APBPeriphClockConfig(__WDG, ENABLE); /* Enable the clock for the WDG peripheral*/
  WDG_DeInit();/* WDG default configuration : Reset configuration*/

  WDG_InitStructure.WDG_Mode = WDG_Mode_Timer;
  WDG_InitStructure.WDG_Preload = 0xFFFF;
  WDG_InitStructure.WDG_Prescaler = 0xFF;
  WDG_InitStructure.WDG_ClockSource=WDG_ClockSource_Apb;

  WDG_Init(&WDG_InitStructure);  /* WDG initialization with the previous chosen parameters.*/

be sure, however, to configure the watchdog's period by the prescaler to service your exact needs.

Read-Only
Author
Per Westermark
Posted
14-Jun-2008 17:11 GMT
Toolset
ARM
New! RE: ARM: SOFTWARE RESET IN C

"if you are using ST's library, you can get away with something like this:"

But he isn't, so he won't :)

The watchdog can be started with:

void wdog_kick(void) {
    // Errata 23xx WDT.1 No APB accesses allowed during feed sequence.
    unsigned prev = VICIntEnable;
    VICIntEnClr=prev;   // Disabling interrupts in the VIC
    WDFEED = 0xAA;
    WDFEED = 0x55;
    VICIntEnable=prev;  // Enabling interrupts in the VIC
}

void wdog_init(void) {
    WDTC = PCLK/4;          // Watchdog timer constant.
    WDMOD = WDEN|WDRESET;   // Reset processor if failure to kick.
    wdog_kick();            // Activate watchdog.
}

Note that even if you want to use the watchdog just go reset your chip, you must kick it once, just to activate it.

But all this is very well described in the user manual!

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings