Sign in to follow this  
Followers 0
juanboy

cc3200 watchdog

9 posts in this topic

Hi, do anybody has a simple software watchdog script for cc3200.

 

Kind of frustrated now as spending a lot of time to build a HW reset,

only to realise that the RESET on the 20 pin connector is only an output...

 

regard,

Share this post


Link to post
Share on other sites

Have not tried it but the Sketch below should give you an idea of how to use the wtachdog on the CC3200. Should work for both EMT and none EMT.

#include <stdio.h>
#include <stdint.h>
#include <inc/hw_types.h>
#include <inc/hw_ints.h>
#include <inc/hw_memmap.h>
#include <driverlib/prcm.h>
#include <driverlib/wdt.h>
#include <driverlib/rom.h>
#include <driverlib/rom_map.h>
#include <driverlib/interrupt.h>
#if defined(USE_TIRTOS) || defined(USE_FREERTOS) || defined(SL_PLATFORM_MULTI_THREADED)
#include "osi.h"
#endif

volatile unsigned long g_ulWatchdogCycles;
#define WD_PERIOD_MS                 1000
#define MAP_SysCtlClockGet           80000000

#define MILLISECONDS_TO_TICKS(ms)    ((MAP_SysCtlClockGet / 1000) * (ms))

void setup()
{
  // put your setup code here, to run once:
      //
    // Enable the peripherals used by this example.
    //
    MAP_PRCMPeripheralClkEnable(PRCM_WDT, PRCM_RUN_MODE_CLK);

    //
    // Unlock to be able to configure the registers
    //
    MAP_WatchdogUnlock(WDT_BASE);

#if defined(USE_TIRTOS) || defined(USE_FREERTOS) || defined(SL_PLATFORM_MULTI_THREADED) 
    // USE_TIRTOS: if app uses TI-RTOS (either networking/non-networking)
    // USE_FREERTOS: if app uses Free-RTOS (either networking/non-networking)
    // SL_PLATFORM_MULTI_THREADED: if app uses any OS + networking(simplelink)
    osi_InterruptRegister(INT_WDT, &WatchdogIntHandler, INT_PRIORITY_LVL_1);
#else
    MAP_IntPrioritySet(INT_WDT, INT_PRIORITY_LVL_1);
    MAP_WatchdogIntRegister(WDT_BASE,&WatchdogIntHandler);
#endif

    //
    // Set the watchdog timer reload value
    //
    MAP_WatchdogReloadSet(WDT_BASE,MILLISECONDS_TO_TICKS(WD_PERIOD_MS));

    //
    // Start the timer. Once the timer is started, it cannot be disable.
    //
    MAP_WatchdogEnable(WDT_BASE);
}

void loop()
{
  // put your main code here, to run repeatedly:
  
}


void WatchdogIntHandler(void)
{
    //
    // Clear the watchdog interrupt.
    //
    MAP_WatchdogIntClear(WDT_BASE);
    //
    // Increment our interrupt counter.
    //
    g_ulWatchdogCycles++;

}
Rei Vilo likes this

Share this post


Link to post
Share on other sites

If the watchdog is used as the program running on the device to loop hangs the watchdog is not activated.

Share this post


Link to post
Share on other sites
On 07/02/2016 at 8:44 PM, energia said:

Have not tried it but the Sketch below should give you an idea of how to use the wtachdog on the CC3200. Should work for both EMT and none EMT.

The example works fine on Energia.

To rearm the watchdog and start to 10 seconds again, just perform

    g_ulWatchdogCycles = 0;

Now, how to deactivate the watchdog?

In a typical application, I want to check one specific part, i.e. WiFi provisioning. The process looks like:

  • Set and start watchdog
  • WiFi provisioning
  • If WiFi provisioning fails, the watchdog resets the board.
  • Stop and clear watchdog

Once this part has been completed successfully, I want to deactivate the watchdog.

 

 

Share this post


Link to post
Share on other sites

The WDT_IF_DeInit function doesn't seem to deactivate the interrupt.

void WDT_IF_DeInit()
{
    //
    // Unlock to be able to configure the registers
    //
    MAP_WatchdogUnlock(WDT_BASE);

    //
    // Disable stalling of the watchdog timer during debug events
    //
    MAP_WatchdogStallDisable(WDT_BASE);

    //
    // Clear the interrupt
    //
    MAP_WatchdogIntClear(WDT_BASE);

    //
    // Unregister the interrupt
    //
    MAP_WatchdogIntUnregister(WDT_BASE);
}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0