0

I'm currently developing an embedded application on Microsemi Smartfusion 2 using FreeRTOS.

It works with no issue when in Debug Mode and also in Run Mode. However, when I don't start the code using the debug/run buttons Eclipse (i.e. when I turn the power off and on again), it starts normally but resets itself a few seconds later. I feel this issue is related to the debugger but I can't solve it.

Any ideas?

EserRose
  • 142
  • 8
  • This is almost certainly a watchdog which has its clock stopped when the debugger puts the part in stop mode. Watchdogs are discussed in learning material for embedded systems beginners. – Lundin Jul 06 '21 at 06:07

1 Answers1

1

Possibly you have a watchdog timer enabled but not serviced that is held-off when the debugger is attached? I am not familiar with the SoC but there is a note to the answer at http://www.actel.com/kb/article.aspx?id=FQ1025:

SoftConsole will automatically disable the watchdog in Debug mode regardless of whether the code is running from eNVM or eSRAM.

Then the first part of that same answer states:

The Watchdog is enabled at power-up and remains so unless explicitly disabled.

So by guess is that you are not servicing the watchdog timer. I'd like to point you at the documentation that makes this clear, but to be frank - I gave up! YMMV. There is a note of the watchdog here.

Clifford
  • 88,407
  • 13
  • 85
  • 165
  • I thought of watchdog timers but didn't know that the debugger disabled it. I actually disable an external watchdog during startup as I thought the internal watchdog would not start unless explicitly called. I'll try disabling it and try again. – EserRose Jul 06 '21 at 11:22
  • @EserRose The documentation for this part and it's tools seems to be all over the place and not particularly clear. Good luck. – Clifford Jul 06 '21 at 12:25
  • The drivers given to me did not include a disable function for watchdog, so I tried implementing it myself but it didn't work (guess they didn't include it for this reason). But I used a task that will reload the watchdog value in regular intervals and it works now. Thank you! – EserRose Jul 06 '21 at 13:02
  • Servicing the watchdog should have been your first choice in any case. Although servicing it in a task unconditionally may not provide good protection. It proves that that task is running - no more. I think you can configure the WDOG to either reset to interrupt. If you configure it to interrupt, and have a _do-nothing but return_ ISR, you effectively disable the watchdog. Otherwise I think disabling it is done using non-volatile option flags. – Clifford Jul 06 '21 at 13:34
  • I tried setting the enable flag of the wd to the disable key given by mss, but it didn't work for some reason. I'll try configuring it to interrupt – EserRose Jul 07 '21 at 10:34