Jump to content
43oh

Recommended Posts

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++;

}
Link to post
Share on other sites
  • 8 months later...
  • 1 year later...
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.

 

 

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);
}

 

Link to post
Share on other sites
  • 1 year later...

Hai,

try this code in CC3220SF internal Watchdog timer program, its working Fine

#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>


int Cycles;
#define WD_PERIOD_MS                 1000
#define MAP_SysCtlClockGet           80000000
#define MILLISECONDS_TO_TICKS(ms)    ((MAP_SysCtlClockGet / 1000) * (ms))

void setup()
{
  Serial.begin(115200);
  Serial.println("Watchdog Test");
  MAP_PRCMPeripheralClkEnable(PRCM_WDT, PRCM_RUN_MODE_CLK);
  MAP_WatchdogUnlock(WDT_BASE);
  MAP_IntPrioritySet(INT_WDT, INT_PRIORITY_LVL_1);
  MAP_WatchdogIntRegister(WDT_BASE, &WatchdogIntHandler);
  MAP_WatchdogReloadSet(WDT_BASE, MILLISECONDS_TO_TICKS(WD_PERIOD_MS));
  MAP_WatchdogEnable(WDT_BASE);
}

void loop()
{
  Serial.println("Watchdog Test");
  delay(2000);
}


void WatchdogIntHandler(void)
{
  if (Cycles >= 10)
  {
    Serial.println("Reseting..........");
    return;
  }
  MAP_WatchdogIntClear(WDT_BASE);
  Cycles++;
}

 

Thanks

Prabuselva

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...