Initialization of Software Watchdog Timer in MPC5748G failed!

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Initialization of Software Watchdog Timer in MPC5748G failed!

跳至解决方案
3,119 次查看
ruuxi1h4cx
Contributor II

     Here is my SWT initialization code, which cannot run correctly. I don't know if my code is correct. Anyone can help me?

void SWT_Init(void)

{

    SWT_0_CR &= ~SWT_CR_WEN_MASK;         /* disable SWT */

    SWT_0_SR = 0xC520;                                        /* unlock SWT */

    SWT_0_SR = 0xD928;

    SWT_0_TO = 0x0000FFFF;                               /* timeout */

    SWT_0_CR &= ~SWT_CR_FRZ_MASK;          /* enable SWT in debug mode */

    SWT_0_CR |= SWT_CR_WEN_MASK;            /* enable SWT */

}

标签 (1)
1 解答
2,322 次查看
petervlna
NXP TechSupport
NXP TechSupport

Hi,

The SWT does not reset the device at all. It is not designed to do it.

The device is reset byt RGM (reset generation module).

When SWT expires the SWT_IR[TIF] flag  is set. When TIF flag is set, the SWT send signal to FCCU module that SWT has expired. Based on FCCU fault configuration the reaction on SWT timeout is taken.

The FCCU module can dirrectly ask RGM module to trigger reset.

SWT is not directly connected to RGM. So it cannot trigger reset as you are expecting.

If you want to trigger reset on SWT timeout then configure FCCU properly.

Peter

在原帖中查看解决方案

8 回复数
2,322 次查看
dhirajbennadi
Contributor I

I initialized the SWT_0 as follows

1) clear soft lock bit 1/2

2) Load count value in SWT_TO register

3) Enabled the watchdog using the WEN bit in SWT_CR register

I checked the SWT_CO register after enabling the SWT but no value is being updated in the register. 

Please provide details regarding the implementation of watchdog timer.

0 项奖励
回复
2,322 次查看
petervlna
NXP TechSupport
NXP TechSupport

To configure FCCU you can follow my guide for Panther.

The procedure is exactly the same:

MPC574xP - FCCU configuration guide

Peter

0 项奖励
回复
2,323 次查看
petervlna
NXP TechSupport
NXP TechSupport

Hi,

The SWT does not reset the device at all. It is not designed to do it.

The device is reset byt RGM (reset generation module).

When SWT expires the SWT_IR[TIF] flag  is set. When TIF flag is set, the SWT send signal to FCCU module that SWT has expired. Based on FCCU fault configuration the reaction on SWT timeout is taken.

The FCCU module can dirrectly ask RGM module to trigger reset.

SWT is not directly connected to RGM. So it cannot trigger reset as you are expecting.

If you want to trigger reset on SWT timeout then configure FCCU properly.

Peter

2,322 次查看
ruuxi1h4cx
Contributor II

Hi,

    Thank you very much! My SWT could reset the device successfully. But another problem occured! My SWT can only reset the device several times. After that, SWT will not reset the device any more! It's so strange!

    Additional, if i write my code into device when the SWT cannot reset the device. The compiler will popup a window " The target may have entered reset escalation. Please power cycle the board".

0 项奖励
回复
2,322 次查看
alexvinchev
Contributor V

ruuxi1h4cx​, please read carefully chapters"55.3.8 'Functional' Reset Escalation Threshold Register (MC_RGM_FRET)", "55.3.9 'Destructive' Reset Escalation Threshold Register (MC_RGM_DRET)", "55.4.6 'Functional' Reset Escalation" and "55.4.7 ‘Destructive’ Reset Escalation". These are pages 2809-2811, 2817 and 2818 from "MPC5748G Reference Manual, Rev. 4, 07/2015"

0 项奖励
回复
2,322 次查看
petervlna
NXP TechSupport
NXP TechSupport

Your code is not correct.

First unlock the SWT with:

SWT_0.SR.R = 0xC520;                               //clear soft lock bit 1/2      

SWT_0.SR.R = 0xD928;                               //clear soft lock bit 2/2

Then you can change configuration of SWT.

Besides have in mind that debugger by default disabling SWT.

Peter

2,322 次查看
ruuxi1h4cx
Contributor II

Thank you!

      Peter.

      I modified my code based on your advice.But even if I don't service the dog all the time, the SWT doesn't reset the device.I don't know why!

Here is my new Init code.

/* software watchdog timer init */

void swt_init(void)

{

    SWT_0.SR.R = 0xC520;             //clear soft lock bit 1/2

    SWT_0.SR.R = 0xD928;             //clear soft lock bit 2/2

    SWT_0.TO.R = 0x100;              //timeout value

    SWT_0.CR.R |= 0xFF000001;        //enable swt

}

Here is my test demo.

int main(void)

{

    uint32_t   temp = FFFFFF;

 

    peri_clock_gating();

    system160mhz();

    xcptn_xmpl();                    /* Configure and Enable Interrupts */

   

   initGPIO();                          /* Initial IO */

    while(temp--);

    LED1 = LED_ON;

   

    swt_init();                           /* Initial SWT */        

   

    for(;;) {                                /* wait until reset */

        //feed_dog();

        LED2 = LED_ON;

    }

    return 0;

}

0 项奖励
回复
2,322 次查看
alexvinchev
Contributor V

Hi,

did you tried first to unlock SWT and then try to change its configuration?

0 项奖励
回复