This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123GH6PM: watch dog timer

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: ENERGIA

Dear Experts,

now i am working with TivaC TM4C123GH6PM an energia. i never work in watch dog timer before so i was rewrite the watch dog timer example code(i get code from google) like below, 

#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/watchdog.h"
#include "driverlib/rom_map.h"
#include "driverlib/rom.h"

void setup()
{
Serial.begin(9600);
Serial.println("SETUP");

MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0); // Enable the watchdog peripheral

MAP_WatchdogReloadSet(WATCHDOG0_BASE, MAP_SysCtlClockGet() * 2); // Set timeout of watchdog to 2 sec

MAP_WatchdogResetEnable(WATCHDOG0_BASE); // Reset when watchdog expires

WatchdogIntRegister(WATCHDOG0_BASE, &WatchdogIntHandler); // Register the watchdog interrupt handler

MAP_WatchdogEnable(WATCHDOG0_BASE); // Enable the watchdog

if(SysCtlResetCauseGet() & SYSCTL_CAUSE_WDOG0) // Get and print the reset cause
{
Serial.println("Watchdog Reset");
}
else if(SysCtlResetCauseGet() & SYSCTL_CAUSE_EXT)
{
Serial.println("External reset");
}

SysCtlResetCauseClear(SYSCTL_CAUSE_WDOG0 | SYSCTL_CAUSE_EXT);
}

void loop()
{
Serial.println("MC Working");
delay(6000);
}

void WatchdogIntHandler(void)
{
WatchdogIntClear(WATCHDOG0_BASE); // Clear the watchdog interrupt.
Serial.println("REG CLEAR");
}

this code reset the watch dog timer register in every 2 sec, so watchdog is not resetting my controller,  my doubt is this code is definitely reset the controller if my controller getting struck or hang for any disturbance.

please make sure about this.

  • Hello Surya,

    Per our TM4C forum guidelines, please direct Energia questions to the primary Energia forums at: forum.43oh.com/.../

  • Hello Jacobi,

    i was open the same thread to energia forum, this is the link for that. https://forum.43oh.com/topic/13494-watchdog-timer/?tab=comments#comment-82279, but still i can't get any answer that's why i ask the question to TI forum and can you help me to write CCS code for TM4C123GH6PM  with HX711 24bit ADC if you help this i can change my code in CCS, i am newbie to TI that's why i ask help to read data from HX711. this is the Energia code for read 24 bit data from HX711 

    unsigned long readRaw()
    {

    byte data[3];
    for (byte j = 3; j--;)
    {
    for (char i = 8; i--;)
    {
    digitalWrite(PD_SCK, HIGH);
    bitWrite(data[j], i, digitalRead(DOUT));
    digitalWrite(PD_SCK, LOW);
    }
    }
    for (int i = 0; i < 1; i++)
    {
    digitalWrite(PD_SCK, HIGH);
    digitalWrite(PD_SCK, LOW);
    }

    data[2] ^= 0x80;

    return ((uint32_t) data[2] << 16) | ((uint32_t) data[1] << :sunglasses: | (uint32_t) data[0];
    }

    or we can write code like this

    bool HX_ready()
    {
    return digitalRead(DOUT) == LOW;
    }

    long HX_read()
    {
    // wait for the chip to become ready
    while (!HX_ready())
    {;}

    unsigned long value = 0;
    uint8_t data[3] = { 0 };
    uint8_t filler = 0x00;

    // pulse the clock pin 24 times to read the data
    data[2] = shiftIn(DOUT, PD_SCK, MSBFIRST);
    data[1] = shiftIn(DOUT, PD_SCK, MSBFIRST);
    data[0] = shiftIn(DOUT, PD_SCK, MSBFIRST);

    // set the channel and the gain factor for the next reading using the clock pin
    for (unsigned int i = 0; i < 1; i++)
    {
    digitalWrite(PD_SCK, HIGH);
    digitalWrite(PD_SCK, LOW);
    }

    // Replicate the most significant bit to pad out a 32-bit signed integer
    if (data[2] & 0x80)
    {
    filler = 0xFF;
    } else
    {
    filler = 0x00;
    }

    // Construct a 32-bit signed integer
    value = ( static_cast<unsigned long>(filler) << 24
    | static_cast<unsigned long>(data[2]) << 16
    | static_cast<unsigned long>(data[1]) << 8
    | static_cast<unsigned long>(data[0]) );

    return static_cast<long>(value);
    }

    but i don't know how to write code in CCS for read the data from HX711.

  • Hello Surya,

    I'm sorry to hear the Energia forum has not been helpful yet.

    Unfortunately we have no Energia experience so we cannot help with it.

    Furthermore, we do not write code examples like what you are asking for, our purpose on E2E is to answer questions about how to properly use the TM4C MCUs. While that includes helping debug code, we don't write code from scratch like this case would require.

    I would suggest you try using TivaWare and read the datasheet for the ADC to understand how you should communicate with it and try to code a working solution that way.

  • Hello Ralph Jacobi,

    thanks for your answer, you said the analog read function will help to read data from HX711, if i write the code with CCS, am i correct or not.