Watch dog strange behaviour

Hi,

I am not sure that this is the right place to ask but I will try ...

I have a strange behaviour of the watch dog timer (Using Arduino NANO). I am using the watch dog timer to initiate periodic tasks. It works excellent without issues only when the serial is connected (only when I conenct to the device with any serial terminal). When I disconnect the teminal the flow is working as expected but the timining is different.

E.g., if I set the watch dog timer to wake up every 4 sec, I run the tasks every 4 counts, which means every 16 sec. When I disconnect the serial connection, it seems to run every 4sec which is very strange.

I assume it difficult to answer my question but what I would like to know if someone has an idea why watch dog timer is affected by serial conenction.

Thx for the help

It's certainly difficult to answer without seeing code, however a watchdog used in that way usually generates an interrupt to wake the processor. Serial input may cause an interrupt and wake the processor.

eyco: I assume it difficult to answer my question

It is difficult to answer without seeing your code. Are you sending anything over the serial interface, or just opening the connection?

There are messages sent with the Serial object.

I also tried to conenct the board to power supply and not to my laptop and it also works fine. I suspect that the serial connection has some affect on the watchdog timer.

One thing that I also noticed is that I have a timer (I am using RTOS) which is used to blink alive led every sec. When the board is conencted to the laptop but the terminal is disconencted I see that every one or two blinks, there is fast blink which I don't see when the terminal is conncted.

Very strange ....

The strange thing so far is that you haven't taken the hint to post your code.

After more testing and removing part of the codes I found out it is not the watch dog, but I still cannot find the cause.

My testing shows:

  1. After I burn the program no issues. I can reset the board with the reset button and it will always start good. 2,. If after I burn the program I disconnect the cable and conenct it again, the problem starts. Reset the board with the reset button will not help.
  2. Using power from power adapter - no issues.
  3. Using second laptop I have - all good.

I suspect now that this is an issue with the laptop driver. I will later try to restart the laptop to see if it helps.

Will update in case others will have similar issues.

eyco: I still cannot find the cause.

That's strange, because [u]you[/u] can see the source code so you're in a [u]far[/u] better position to understand the problem than we are.

One thing that I also noticed is that I have a timer (I am using RTOS)

Which RTOS? Have you consulted the RTOS documentation? Inside most RTOS schedulers, there are strict rules on I/O and interrupt services since the supervisory code must maintain state timing which require hardware resources.

Ray

The issue wasn't related to the RTOS or any other code. I have commentd almost everything and the problem still occured. Only after restarting my laptop issue solved.

I understand that the DTR is the one which is connected to the arduino reset. I suspect that somehow the laptop / driver toggled the DTR if the conenction wasn't active.

And again, it wasn't related to the arduino code.

eyco: And again, it wasn't related to the arduino code.

If you believe that's true then I suggest you create the simplest possible sketch which demonstrates the problem, making as little use as possible of any third part or non-standard libraries / operating systems, and post that so we can get an idea of what's going on.

Simply commenting that you don't think it's a code issue isn't helping us - since you clearly don't know what is causing the problem, by the same token at this stage it's very hard to say what [u]isn't[/u].

I understand that the DTR is the one which is connected to the arduino reset. I suspect that somehow the laptop / driver toggled the DTR if the conenction wasn't active. And again, it wasn't related to the arduino code.

I am in PeterH's camp on this one. It is highly unlikely in my opinion that the laptop+driver software is to blame. If it were the driver, my guess is that your hardware presented something to the USB interface.

Two paths... 1) Continue down Arduino road giving the appropriate Arduino code and RTOS, versions, configurations, etc. 2) Continue with your deduction and mark the thread solved

Ray

eyco: And again, it wasn't related to the arduino code.

So the watchdog problem is solved then? If it is nothing to do with code?

It is not the watchdog as I thought from the start because when I remove the watch dog issue I still got the problem. Only after I have restart my laptop it was solved.

Please not that before I have restarted the laptop I have checked it on direct power conenction and on other laptop which showed clearly that the issue is not with the arduino / software.

I am 99% sure this is the case but I will wait a little just to see if I encounter issue again or not.

Currenlty I don't see this issue.