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.

CCS/CC1310: Stop watchdog before entering sleep mode

Part Number: CC1310

Tool/software: Code Composer Studio

Hi

I have a running application, and I am now working on implementing watchdog.

I set up the watchdog for RESET, and this works fine: When I stop feeding (Watchdo_clear()), it resets as it is supposed to do.

So far, so good.

But when my application enters sleep mode, it seems like the watchdog is still running, and my application resets.

As I read the documentation and other forum posts, the WD should not be running during sleep?

I have then tried to stop the watchdog, bu calling Watchdog_Close().

But this has no effect. The aaplication still resets after putting it to sleep.

This is my code for starting the watchdog:

Watchdog_Params_init(&params);

params.resetMode = Watchdog_RESET_ON;

watchdogHandle = Watchdog_open(Board_WATCHDOG0, &params);

Watchdog_setReload( watchdogHandle, 800000 );

And I try to stop it like this:

Watchdog_clear( watchdogHandle );
Watchdog_close( watchdogHandle );

Why can't I stop the watchdog?

Thanks

Kaare

  • The watchdog is not running in standby which indicate that you are not in standby.

    Do you know that it's the watchdog that resets the application when you are in standby?
  • Hi TER

    Sorry for late reply, I did not see your response until now.

    When I enter sleep, I call this:

    Semaphore_pend( semC_Main, BIOS_WAIT_FOREVER);

    If I have initiated/started the WD, the application never starts again, as it does when I skip the WD init.

    I have a bootloader running from 0x0000, and the application from 0x0000'1000.

    As I see it, the application enters sleep, resets, and starts up in the bootloader, where it is stuck (I have not had the chance to find out if the bootloader actually is entered).

    Even if I call the WD close function, this happens, so it MIGHT be that it is not the bootloader.

    But I do not do anything than starting the WD, and then close it before entering sleep.

    Any ideas why the application stops/resets?

    Thanks Kaare

  • How do you know that the system goes to sleep when you do Semaphore_pend( semC_Main, BIOS_WAIT_FOREVER); ?

    This statement ensures that other tasks could run while pending on the semaphore, does that mean you have only one task?

    Have you tried to run the ROV when you get into the state where the application never starts to see what is running?
  • I only have one task, yes. And the current consumption indicates clearly that it is sleeping :)

    Tried to run the ROV, but I'm not familiar with it, so I think I need a little help to what to do ?

    br

    Kaare

  • Have you checked if this is tied to the bootloader implementation in some way by running the same program but without the bootloader?
  • I have now tested without bootloader on the target, but same happens:

    1) When I enable the WD, and enters sleep, the MCU "resets" -> The JTAG interface is cut, and firmware not running

    2) When application is running, with WD enabled, and I call Watchdog_close(), same thing happens: JTAG connection dies, and firmware stops running.

    br
    Kaare
  • Would you be able to post a minimum project that runs on a launchpad that shows this issue?
  • That would be possible, but it will take some time, and right now, I don't have a Launchpad board.

    I have ordered a couple of them, but have not received them yet, and they will be used for another project the first week.

    But I have tested some more, and tried to reset bu calling SysCtrlSystemReset(). For now, I only use the WD to reset the system, so I am happy if I can succeed to reset the application.

    When calling this, the same thing happens: Debugger is cut off, and MCU seems to halt somewhere: Everything stops. Also if I have detached the debugger before trying to reset.

    When I make a power cycle, the bootloader starts as expected, and jumps to application as expected.

    So, everything works, but something is keeping the MCU from starting up from a software reset.

    I seems like it is not a specific WD issue, but a software reset issue.

    br

    Kaare

  • Hello,

    I'm interesting in this topic because I have a similar problem.

    I have a project based on the Node-Concentrator example. The project of my "node" has 3 tasks:

    • The first one (handler task) wakes up every 5 seconds and after the execution of some functions it generates an event which start a radio communication (radio task);
    • The  radio task, which was waiting for the event from the handler task, sends a message to the "concentrator" and then waits for a reply;
    • When a reply message is received or a timeout is detected, the third task, which was waiting on an event from the radio task, enetrs in execution and executes some functionalities. Then the micro goes to sleep again.

    If I have understood well, the watchdog doen't work when the micro goes to sleep. So we have thought two ways to restart the board in case of problems:

    • implement a timeout based on the clock driver which executes the SysCtrlSystemReset() function in case of expiration. The meaning of this is to avoid that something happens and the handler task is not executed anymore and the micro remains in sleep mode forever. The handler task restart the clock any cycle;
    • this idea in our opinion could be not enough, so we would like to use the watchdog in order to restart in case of problems in the execution of our code, for example in a hardware ISR.

    Everything seems working: the clock expires if I blocked the handler task on a while(1) cycle but also if I call the Task_sleep with a big timeout. If the handler task is blocked, the other task can't go in execution and this is verified.

    My question is related to the watchdog. If I block the handler task on a while(1) cycle I can see the callback function of the watchdog working as waited. The same happens if I block an HW ISR.

    The behaviour I don't understand is when I put the handler task on a big Task_sleep (bigger then the watchdog timeout): beeing all the task blocked on an event or on the Task_sleep, the micro is in sleep mode, so I think that the watchdog shouldn't count anymore. In this situation I see that the callback function of the watchdog is executed after the timeout. And if I configure the watchdog to restart, the board restart.

    Please, can you explain the reason of this? And can you indicate me the mistake in may idea?

    I hope my explanation is clear... thanks, Andrea.

  • Hi TER

    I have used all day to try out different ways to make the reset/jump from Main application to Bootloader and back.
    Played around using both SysCtrlSystemReset(), Watchdog reset and Jump to startadress.
    SysCtrlSystemReset() was no success, but I did not test much on that.
    Watchdog reset seems to be able to reset, and start bootloader, but then it dies during bootloading. I guess it is because Watchdog still runs during bootloader, even though the Watchdog did a RESET. Does the Watchdog keep running.

    I have some success using JUMP to bootloader start address 0x0000:
    asm(" MOV R0, #0x00000 ");
    asm(" LDR R1, [R0, #0x4] ");
    asm(" LDR SP, [R0, #0x0] ");
    asm(" BX R1 ");

    Using this to jump to Bootloader, it runs like this:
    1. Copy new image to external FLASH
    2. Jump to Bootloader / 0x0000
    3. Bootloader flashes image
    4. Jump to application / new image.
    The above works perfect.

    But if I let the system go into sleep (auto sleep after 5 minutes without user action), the jump to main application halts the MCU (or it looks like this):
    1. Let application enter sleep mode
    2. Copy new image to external FLASH
    3. Jump to Bootloader / 0x0000
    4. Bootloader flashes image
    5. Jump to application / new image.
    6. MCU HALTS -> Everything stops
    ________________________________
    7. Powercycle
    8. Bootloader checks if there is new firmware to flash
    9. No new firmware -> Jump directly to main application.
    10. Main application starts up with the new version, just FLASHED by the bootloader.
    11. Repeat with new firmware, but before sleep mode, works fine.

    The 10.000 dollar question: Why halts the execution when jumping to main application, first time after sleep mode?

    I have no clue right now, what can make this happen, so if you have a clue where to search, I would be happy :)

    Ps: Some of my struggling seems to be because the reset/jump is troublesome when the debugger hardware is connected, even though I am not debugging. All the above tests are done with debugger hardware disconnected.
    Thanks
    Kaare

  • Excuse me, I reply to my post because I suppose to have done a big problem... I thinkl that I've seen the restart caused by the watchdog just when I was in debug mode and the micro shouldn't go never in sleep in this condition.

    Sorry again for my question... If you wanted to give me your opinion about my system restart I would appreciate it. We can't use an external watchdog becuase we have found just too expensive components or components not good about the consumption.

    I have another question: is there the possibility to know the cause of previous reset of the CC1310? Like a register where it is possibile to read if the system is arriving from a power-on reset, from a watchdog reset or from a SysCtrlSystemReset reset?

    Thanks again, Andrea

  • Hi Andrea,

    The watchdog driver does not implement "close". Once it is started, you are unable to stop the watchdog using the driver.

    As for the reset stalls, this is expected behavior as long as the debugger is attached. If the debugger is attached to the device, it will halt in boot during reset (for debugging purposes). If you disconnect the debugger, the device should restart as expected.

    You can use the SysCtrlResetSourceGet() API to get the source of the reset, which sources you can expect is part of the API documentation.