AnsweredAssumed Answered

Watchdog Interrupt

Question asked by David XY Zhou on Sep 21, 2016
Latest reply on Feb 6, 2017 by David XY Zhou

Hi,

 

I have K60 towerboard:_K60P144M150SF3RM , MQX 4.2 Code Warrior v10.6.4

Using PE generated Watchdog with Interrupt then Reset CPU option:

The interrupt is INT_Watchdog,

but I cannot find anything in the Init() generated code that the INT_Watchdog is associated with any ISR.

LDD_TDeviceData* WDog1_Init(LDD_TUserData *UserDataPtr)
{
  /* Allocate device structure */
  WDog1_TDeviceData *DeviceDataPrv;

 

 

  /* {MQX RTOS Adapter} Driver memory allocation: RTOS function call is defined by MQX RTOS Adapter property */
  DeviceDataPrv = (WDog1_TDeviceData *)_mem_alloc_system((_mem_size)sizeof(WDog1_TDeviceData));
  #if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
  if (DeviceDataPrv == NULL) {
    return (NULL);
  }
  #endif
  DeviceDataPrv->UserDataPtr = UserDataPtr; /* Store the RTOS device structure */
  /* {MQX RTOS Adapter} Critical section begin (RTOS function call is defined by MQX RTOS Adapter property) */
  _int_disable();
  /* WDOG_UNLOCK: WDOGUNLOCK=0xC520 */
  WDOG_UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xC520); /* Key 1 */
  /* WDOG_UNLOCK: WDOGUNLOCK=0xD928 */
  WDOG_UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xD928); /* Key 2 */
  /* WDOG_WINH: WINHIGH=0 */
  WDOG_WINH = WDOG_WINH_WINHIGH(0x00); /* Setup window register high */
  /* WDOG_WINL: WINLOW=0 */
  WDOG_WINL = WDOG_WINL_WINLOW(0x00);  /* Setup window register low */
  /* WDOG_TOVALH: TOVALHIGH=0xE0 */
  WDOG_TOVALH = WDOG_TOVALH_TOVALHIGH(0xE0); /* Setup time-out value register high */
  /* WDOG_TOVALL: TOVALLOW=2 */
  WDOG_TOVALL = WDOG_TOVALL_TOVALLOW(0x02); /* Setup time-out value register low */
  /* WDOG_PRESC: ??=0,??=0,??=0,??=0,??=0,PRESCVAL=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
  WDOG_PRESC = WDOG_PRESC_PRESCVAL(0x00); /* Setup status register */
  /* WDOG_STCTRLL: INTFLG=1,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=1 */
  WDOG_STCTRLL = (WDOG_STCTRLL_INTFLG_MASK | 0x01U); /* Setup status register */
  /* WDOG_STCTRLH: ??=0,DISTESTWDOG=1,BYTESEL=0,TESTSEL=0,TESTWDOG=0,??=0,??=1,WAITEN=1,STOPEN=1,DBGEN=0,ALLOWUPDATE=0,WINEN=0,IRQRSTEN=1,CLKSRC=1,WDOGEN=1 */
  WDOG_STCTRLH = WDOG_STCTRLH_DISTESTWDOG_MASK |
                 WDOG_STCTRLH_BYTESEL(0x00) |
                 WDOG_STCTRLH_WAITEN_MASK |
                 WDOG_STCTRLH_STOPEN_MASK |
                 WDOG_STCTRLH_IRQRSTEN_MASK |
                 WDOG_STCTRLH_CLKSRC_MASK |
                 WDOG_STCTRLH_WDOGEN_MASK |
                 0x0100U;              /* Setup control register */
  /* {MQX RTOS Adapter} Critical section ends (RTOS function call is defined by MQX RTOS Adapter property) */
  _int_enable();
  /* Registration of the device structure */
  PE_LDD_RegisterDeviceStructure(PE_LDD_COMPONENT_WDog1_ID,DeviceDataPrv);
  return ((LDD_TDeviceData *)DeviceDataPrv); /* Return pointer to the device data structure */
}

 

Where is the interrupt routine for INT_Watchdog? Do I have to install myself?

 

In the example, watchdog.c under mqx example folder, it shows a watchdog test using system timer as watchdog. It can call interrupt when specified time duration expires. It can be added with a CPU reset in the ISR(). To me, this is the same as watchdog timer defined with interrupt and then reset CPU. What are essential difference between Watchdog timer and a system timer is used as watchdog function? 

 

Thank you,

David Zhou

Outcomes