This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Reset F28335 by using WDT via software

Hi Champs,

I would like to reset F28335 by using software force a watchdog reset, as it's the suggested workaround of 'Possible Incorrect Operation of XINTF Module After Power Up'. But I can not seem a watchdog reset using below code:

   EALLOW;
   if(!(SysCtrlRegs.WDCR & 0x0080)) // if there is a watchdog reset
   {
          SysCtrlRegs.WDCR = 0x00A8; // enable watchdog
          SysCtrlRegs.WDCR = 0x0000; // reset
   }
   SysCtrlRegs.WDCR = 0x00E8; //disable watchdog
   EDIS;

very interesting is that, when I insert some NOP before'disable' watchdog, I can see the watchdog reset. the code as below:

   EALLOW;
   if(!(SysCtrlRegs.WDCR & 0x0080)) // if there is a watchdog reset
   {
          SysCtrlRegs.WDCR = 0x00A8; // enable watchdog
          SysCtrlRegs.WDCR = 0x0000; // reset
   }
   asm ("NOP");
   asm ("NOP");
   asm ("NOP");
   SysCtrlRegs.WDCR = 0x00E8; //disable watchdog
   EDIS;

I am not sure why watchdog NOT reset device while the reset watchdog statement followed by a disable watchdog statement. Could you please tell me why? thanks!

  • Hi Gavin,

    Could you send the assembly code for this?. Once we enable the reset via WD, it takes few CPU cycles to start the reset cycle but since there is WD disable code just after that it look like due to race condition reset cycle does not complete. If you put the WD disable code in else statement then this should be ok. I'll look into this further and provide you update. Meanwhile please send me the assembly code.

    Regards,

    Vivek Singh
  • Hi Vivek,

    Great to see you.

    please find the C code vs assembly code as below,  thanks!

    line:36    EALLOW;
    line:37   if(!(SysCtrlRegs.WDCR & 0x0080)) // if there is a watchdog reset
    line:38   {
    line:39          SysCtrlRegs.WDCR = 0x00A8; // enable watchdog
    line:40          SysCtrlRegs.WDCR = 0x0000; // reset
    line:41   }
    line:42   SysCtrlRegs.WDCR = 0x00E8; //disable watchdog
    line:43   EDIS;
    
    
    	.dwpsn	file "../Example_2833xLEDBlink.c",line 36,column 4,is_stmt,isa 0
     EALLOW
    	.dwpsn	file "../Example_2833xLEDBlink.c",line 37,column 4,is_stmt,isa 0
            MOVW      DP,#_SysCtrlRegs+25   ; [CPU_U] 
            TBIT      @_SysCtrlRegs+25,#7   ; [CPU_] |37| 
            B         $C$L1,TC              ; [CPU_] |37| 
            ; branchcc occurs ; [] |37| 
    	.dwpsn	file "../Example_2833xLEDBlink.c",line 39,column 11,is_stmt,isa 0
            MOVB      @_SysCtrlRegs+25,#168,UNC ; [CPU_] |39| 
    	.dwpsn	file "../Example_2833xLEDBlink.c",line 40,column 11,is_stmt,isa 0
            MOV       @_SysCtrlRegs+25,#0   ; [CPU_] |40| 
    $C$L1:    
    	.dwpsn	file "../Example_2833xLEDBlink.c",line 42,column 4,is_stmt,isa 0
            MOVB      @_SysCtrlRegs+25,#232,UNC ; [CPU_] |42| 
    	.dwpsn	file "../Example_2833xLEDBlink.c",line 43,column 4,is_stmt,isa 0
     EDIS
    

  • HI Gavin,

    As mentioned earlier, if after writing BAD KEY, immediately good key is written then effect of BADKEY is lost hence reset does not happen. As suggested, please use else statement for WD disable code.

    Regards,
    Vivek Singh