Mouser Left Banner
Mouser Left Banner
Mouser Left Banner
Mouser Right Banner
Mouser Right Banner
Mouser Right Banner
More

    Improving IoT System Robustness Using Watchdog Timers

    That said, it’s the smart watchdog software that truly makes the watchdog “smart” and that’s where developers need to pay attention and create a little bit of code. Be aware that the code doesn’t have to be complicated, in fact, the simpler the better! Small, simple, provable software is best for a watchdog. A simple code example for the MSP430, inspired by the TPL5010 Evaluation Module documentation, is shown (Code listing):

    static volatile bool Reset = true;
    void main(void)
    {
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
    P1OUT |= BIT0; // Set P1.0 to high
    P1DIR |= BIT0; // Set P1.0 to output direction
    P1DIR &= ~BIT1; // Set P1.1 to input direction
    P2IES &= ~BIT0; // P2.0 Lo/Hi edge
    P2IFG &= ~BIT0; // P2.0 IFG Cleared
    P2IE |= BIT0; // P2.0 Interrupt Enabled

    while(1)
    {
    __delay_cycles(500000); // Set Delay

    // If true then the heartbeat was not received
    if(Reset == true)
    {
    // The heartbeat was not received. Reset the processor
    P1OUT &=~ BIT0;
    __delay_cycles(100); // Set Delay
    P1OUT |= BIT0;
    Reset = false;
    }
    else
    {
    Reset = true;
    }
    }
    }
    // Port 2 interrupt service routine
    #pragma vector=PORT2_VECTOR
    __interrupt void Port_2(void)
    {
    P2IFG &= ~BIT0; // P2.0 IFG Cleared
    P2IE |= BIT0; // P2.0 Interrupt Enabled
    Reset = false;
    }

    Code listing: Example MSP430 software to monitor the microcontroller heartbeat. If the heartbeat is not received within the expected period, then the microcontroller is reset. (Source: Inspired by Texas Instruments’ SNAU173 Application Note).

    The example code shows the smart watchdog being initialized and then waiting a specific time before checking to see if the microcontroller should be restarted. The smart watchdog sets the Reset variable to true, assuming that the microcontroller has failed. It is up to the microcontroller to send the heartbeat pulse, which triggers the interrupt that sets the Reset variable back to false. There are plenty of features that could be added to the sample code such as:

    • Windowed watchdog
    • Entering low power states
    • Clearing the TPL5010 that is watching the smart watchdog
    • Monitoring communication lines
    • Tracking how many resets have occurred
    • The possibilities are limited only by what is truly necessary to ensure a robust design.

    Conclusion
    Security for the IoT is important, but developers would do well to not lose sight of system robustness. For this, watchdogs are going to play a critical role in the IoT as devices are not only deployed into the field far from human access, but are also expected to operate nearly flawlessly 24 hours a day, 7 days a week. Internal watchdogs provide developers with minimal recovery opportunities, while external watchdogs and smart watchdogs with a bit of extra software, open the field to robust and recoverable designs.

    ELE Times Bureau
    ELE Times Bureauhttps://www.eletimes.com
    ELE Times provides a comprehensive global coverage of Electronics, Technology and the Market. In addition to providing in depth articles, ELE Times attracts the industry’s largest, qualified and highly engaged audiences, who appreciate our timely, relevant content and popular formats. ELE Times helps you build awareness, drive traffic, communicate your offerings to right audience, generate leads and sell your products better.

    Technology Articles

    Popular Posts

    Latest News

    Must Read

    ELE Times Top 10