This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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

Parents
  • 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.

Reply
  • 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.

Children
  • "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!