AnsweredAssumed Answered

how to use hardware watchdog  in mqx

Question asked by 骑 天马 on Jun 13, 2013
Latest reply on Jun 23, 2013 by 骑 天马

dear sir

 

I am new to MQX RTOS ,and  my board is kinetis k60n512 tower system  and I use the IAR compiler. I really do not find the IO DRIVRE for hardware  wathchdog  in max ,so I choose to directly  control the  registers belong to the hardware wathchdog .

I find a problem  . hardware watchdog  work  ,but the watchdog time is always the same  and I had changed the time register  to 10s,but the mcu restart in a time less than 1s   .code is blow .

 

 

static void wdog_unlock(void)
{
    _int_disable;
  WDOG_UNLOCK=0xC520;
WDOG_UNLOCK=0xD928;
_int_enable;

}
void wdog_init(unsigned int time)
{
  time=9.6*(10^6)*time;
  wdog_unlock();
  WDOG_PRESC=0x0400;
  WDOG_TMROUTH=0x05B8;//restart   time is 10s
WDOG_TMROUTL=0xD800;


  WDOG_STCTRLH=0x01d3;


}


void wdog_feed(void)
{
  wdog_unlock();
  WDOG_PRESC=0x0400;
  WDOG_REFRESH=0xA602;
  WDOG_REFRESH=0xB480;


}


void main_task
   (
      uint_32 initial_data
   )
{
   _task_id   task_id;
   _mqx_uint  i;
   _int_disable;
int n=10000 ;
wdog_init(100);


   printf("restart");
  


  while(1)
  {
  printf(" ok");
  _time_delay(50);
   
  }


}

Outcomes