MQX SW Watchdog

cancel
Showing results for 
Search instead for 
Did you mean: 

MQX SW Watchdog

Jump to solution
666 Views
csmgsarma
Contributor IV

Dear List,

I am using TWRK64 board with MQX4.2 on KDS V3. I was looking into the watchdog example(the only reference for MQX Watchdog I could come across!). The _watchdog_XXX APIs are poorly documented and there is no clarity on the usage of these apis. 

I'ld appreciate if any usage and examples are shared. 

Best regards

Sarma

Tags (3)
1 Solution
310 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi CSMG Sarma

Please refer to the MQX Reference Manual in the MQX installation folder, section 2.1.138--2.1.351 describers the _watchdog_xxx API.

pastedImage_1.png

Please also refer to the watchdog demo

Freescale_MQX_4_2\mqx\examples\watchdog

Regards

Daniel

------------------------------------------------------------------------------------------

If this post is helpful, please click correct or helpful button, thank you

--------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
3 Replies
311 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi CSMG Sarma

Please refer to the MQX Reference Manual in the MQX installation folder, section 2.1.138--2.1.351 describers the _watchdog_xxx API.

pastedImage_1.png

Please also refer to the watchdog demo

Freescale_MQX_4_2\mqx\examples\watchdog

Regards

Daniel

------------------------------------------------------------------------------------------

If this post is helpful, please click correct or helpful button, thank you

--------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
310 Views
csmgsarma
Contributor IV

Hi danielchen@fsl

I had figured it out. Didn't close the request.  Implementation includes a K64 system reset as watchdog ISR. It is as follows:

/*******************************************************************************
* \brief initializes the MQX watchdog timer and runs it for ever. Created by Main_task.
* @param initial_data task data. Usually NULL
*
*******************************************************************************/
void wdt_task(uint32_t initial_data)
{
        MQX_TICK_STRUCT ticks;
        _mqx_uint       result;
        _mqx_uint       n;


        result = _watchdog_create_component(BSP_TIMER_INTERRUPT_VECTOR,
           system_reset);
        if (result != MQX_OK)
        {
           printf("\nError creating watchdog component.");
           _task_block();
        }
        else
        {
             printf("Watchdog created successfully\n");
        }

        while (TRUE)
        {
           result = _watchdog_start(WATCHDOG_SLEEP_TIME + 10);//!to address the context switch delays a short 10ms delay added.
           _time_delay(WATCHDOG_SLEEP_TIME);
           _watchdog_stop();
        }
}


/*******************************************************************************
* \brief Resets the K64 microcontroller. This is also the watchdog ISR handler
* \note this doesn't check to stop tasks but directly resets the K64 micro.
*
* @see <a href="https://community.nxp.com/thread/99740">MQX Community</a>
* @see <a href="https://mcuoneclipse.com/2015/07/01/how-to-reset-an-arm-cortex-m-with-software/">MCU on Eclipse</a>
*******************************************************************************/
void system_reset(void * ptr)
{
     (void)ptr;
//     SCB->AIRCR = 0x05FA0002;
//     SCB_AIRCR_REG() =
#if KIN1_IS_USING_KINETIS_SDK
     SCB->AIRCR = (0x5FA<<SCB_AIRCR_VECTKEY_Pos)|SCB_AIRCR_SYSRESETREQ_Msk;
#else
     SCB_AIRCR = SCB_AIRCR_VECTKEY(0x5FA) | SCB_AIRCR_SYSRESETREQ_MASK;
#endif

     while(1)
          ;
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

Best regards

Sarma

310 Views
sudhanshumehta
Contributor IV

good answer.. Worked for me on K70

0 Kudos