how to use hardware watchdog in mqx

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to use hardware watchdog in mqx

Jump to solution
1,314 Views
骑天马
Contributor I

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);

  

  }

}

0 Kudos
1 Solution
503 Views
Martin_
NXP Employee
NXP Employee

write timeout value to TOVALH and TOVALL registers. _int_enable should be removed from wdog_unlock and put it to the end of wdog_init().

View solution in original post

0 Kudos
2 Replies
504 Views
Martin_
NXP Employee
NXP Employee

write timeout value to TOVALH and TOVALL registers. _int_enable should be removed from wdog_unlock and put it to the end of wdog_init().

0 Kudos
503 Views
骑天马
Contributor I

thanks a lot .I mistake the register name because a book i read  ,and i had not read the datasheet carefully.

thanks again.

0 Kudos