Author Topic: WatchDog  (Read 6663 times)

Offline cagdask

  • Newbie
  • *
  • Posts: 4
    • View Profile
WatchDog
« on: April 09, 2011, 02:40:40 PM »
Hi all,
I am having trouble with my app. It simply has 2 tasks one for  general application and the other for receiving/sending rs485 commands from  uart2. Here is a gist of  : my task table

{ "Wdog",      fnTaskWatchdog, NO_QUE,   0, (DELAY_LIMIT)( 0.3 * SEC ),  UTASKER_GO},
  { "app",       fnApplication,  MEDIUM_QUE,  (DELAY_LIMIT)((0.10 * SEC) + (PHY_POWERUP_DELAY)), 0, UTASKER_STOP}, // Application - start after Ethernet to be sure we have Ethernet handle
  { "X-turnstile-application",       fnTurnstileApplication,  LARGE_QUE,  (DELAY_LIMIT)(2 * SEC),(DELAY_LIMIT)(0.1 * SEC),  UTASKER_STOP},  // main application
  { "x-PP_Receive", fnTaskPPReceive, LARGE_QUE,   (DELAY_LIMIT)(NO_DELAY_RESERVE_MONO), 0,  UTASKER_STOP}, // uart receiving task

Here is an debug output from uart0

APP is working
Turnstile app is working
pp receive started to work
App is working

I assume that while PP is working device restarts maybe because of watchdog. So in gist, how can i kick the watchdog to prevent it from resetting?

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: WatchDog
« Reply #1 on: April 09, 2011, 05:24:10 PM »
Hi

The watchdog task is scheduled to operate once every 0.3s and so, if there is nothing stopping it, it should retrigger then watchdog adequately fast.

However, if your application task is stopping other tasks from running (eg. it is stuck in a forever loop) the watchdog task will not run and so the watchdog will fire. Therefore check that the application task is only running for a short time.

Another possibility is that the application task (presumably the last one that was started) causes an exception (bad memory access) and so the processor jumps to the exception handler, which stops the system and causes the watchdog to fire.

Try temporarily disabling the watchdog and seeing whether the code gets stuck in code or an exception - with a debugger this should be easy to see.

Regards

Mark

Offline cagdask

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: WatchDog
« Reply #2 on: April 11, 2011, 09:31:21 AM »
Well i'm totally confused
this code prints "i am in" message if last line of code at the bottom is removed. After adding
    readBytes = fnRead(PortIDInternal, ucInputMessage, HEADER_LENGTH);   // after i add this line program resets
it only prints "trying to get in 'while'" then stucks and watchdog does the work... It doesn't sound rational to me...

void fnTaskPPTimeout(TTASKTABLE *ptrTaskTable)
{
    unsigned char ucInputMessage[HEADER_LENGTH];                  // reserve space for receiving messages
    QUEUE_HANDLE PortIDInternal = ptrTaskTable->TaskID;           // queue ID for task input   
   unsigned char readBytes = fnRead(PortIDInternal, ucInputMessage, HEADER_LENGTH);
   fnDebugMsg("trying to get in 'while' ");
  while(readBytes)
  {
    // check input queue
    switch (ucInputMessage[MSG_SOURCE_TASK])
    {
      case TIMER_EVENT:
        if (GEMPROX_READ_TIMEOUT_BASE == (ucInputMessage[MSG_TIMER_EVENT] & 0x0F))
        {
          ucTNAD = NOT_FOUND;
          uiBytesStore = 0;
          fnDriver(ppSerialPortID, (MODIFY_CONTROL | SET_RTS), 0);
          fnAwakeTL(ERR_READER_MUTE, &ucReceiveBuffer[0], 0); 
         fnDebugMsg("i am in");
        }
    }
    readBytes = fnRead(PortIDInternal, ucInputMessage, HEADER_LENGTH);   // after i add this line program resets
  }   
}

Offline cagdask

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: WatchDog
« Reply #3 on: April 12, 2011, 11:50:21 AM »
found the silly mistake :) 'case' has no 'break' in it :)