WatchDog Configuration of s9keazn8

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

WatchDog Configuration of s9keazn8

Jump to solution
1,900 Views
fanziyu
Contributor IV

Hi,everyone.

I have got a problem with WatchDog Configuration of the s9keazn8.

Mcu:s9keazn8    ;

Tool: PE micro multilink universal

software:S32 Design Studio for ARM;Version: 2018.R1

I use the following code  ; I do not get 1s periodic reset but get 51s periodic

#define DisableInterrupts asm("CPSID i")
#define EnableInterrupts asm("CPSIE i")

void WatchDogCfg(void)

{

   DisableInterrupts;
   WDOG_CNT = 0X20c5;
   WDOG_CNT = 0X28d9;
   WDOG_TOVAL = 1000;// 1s times out
   WDOG_CS2 = 0x01;
   WDOG_CS1 = WDOG_CS1_EN_MASK;
   EnableInterrupts;

}

void main(void)

{

   WatchDogCfg();

   SIM_SOPT = 0X0000000C;//NMIE:when clear,the pin functions as one of its alternative functions

   ClockCfg();
   PortCfg();

   GPIOA_PSOR |= 1<<13;//Light the LED A

   for(;;)

   {

      #if 0                    // if I don't feed the dog then the mcu will reset and will light off the LED A 
         DisableInterrupts;
         WDOG_CNT = 0X2A6;
         WDOG_CNT = 0X80B4;
         EnableInterrupts;
      #endif

    }

}

pastedImage_16.png

So  i wonder if it has anything to do with starup_code ——void SystemInit (void) .I find that the watchDog is configurated in it.But UPDATE bit is set,so I think it is ok.

what i have done:

1:WDOG->TOVAL = WDOG_TOVAL_TOVAL(0xE803); /* Timeout value */ 

  ——》WDOG->TOVAL = WDOG_TOVAL_TOVAL(1000);

result:  the periodic is 51s too;

2:I use my code instead in the void SystemInit (void)
WDOG_CNT = 0X20c5;
WDOG_CNT = 0X28d9;
WDOG_TOVAL = 1000;
WDOG_CS2 = 0x01;
WDOG_CS1 = WDOG_CS1_EN_MASK;
#if 0
   #if (DISABLE_WDOG)
   /* WDOG->TOVAL: TOVAL=0xE803 */
   WDOG->TOVAL = WDOG_TOVAL_TOVAL(0xE803); /* Timeout value */
   /* WDOG->CS2: WIN=0,FLG=0,?=0,PRES=0,?=0,?=0,CLK=1 */
   WDOG->CS2 = WDOG_CS2_CLK(0x01); /* 1-kHz clock source */
   /* WDOG->CS1: EN=0,INT=0,UPDATE=1,TST=0,DBG=0,WAIT=1,STOP=1 */
   WDOG->CS1 = WDOG_CS1_UPDATE_MASK |
   WDOG_CS1_TST(0x00) |
   WDOG_CS1_WAIT_MASK |
   WDOG_CS1_STOP_MASK;
   #endif /* (DISABLE_WDOG) */
#endif

result:  the periodic is 51s too;it looks llike somewhere else what i don't find.

Last is how i load the code into the actrual mcu: I don't configurate anything ,choose 1 and press 2.

Is there any problem?

pastedImage_20.png

0 Kudos
Reply
1 Solution
1,574 Views
FelipeGarcia
NXP Employee
NXP Employee

Please check my answers below:

 

1. This could be caused because Run out of reset puts a core in run mode after reset. Please check below document.

http://cache.freescale.com/files/soft_dev_tools/doc/user_guide/CW_PA_CF_UG.pdf

 

2. If you check the Peripheral register structure for WDOG in SKEAZN84.h you could see the following:

pastedImage_10.png

As you can see TOVALH is set first when using TOVAL struct.

 

3. I think the following post could help you to use NMI pin as GPIO.

https://community.nxp.com/thread/455185 

Hope it helps!

 

Best regards,

Felipe

View solution in original post

0 Kudos
Reply
9 Replies
1,574 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi,

 

Please refer to the SDK driver for S32DS, there is a wdog driver included that you can take as reference.

https://www.nxp.com/downloads/en/device-drivers/SDK-DRIVER-FRDM-KEA-S32DS.zip

 

Regarding your second question, do you have an issue flashing the code? If so, could you please show me what errors are you facing?

 

Best regards,

Felipe

0 Kudos
Reply
1,574 Views
fanziyu
Contributor IV

I am using S32DS to flash program and debug a S9keazn8 and all is fine,(except watchdog).  What I want to do is program it so that it runs from reset without the debugger pod attached.  When I reset the microcontroller (by Power on) the firmware in flash doesn’t run, with or without the debugger attached.  I've recently migrated to S32DS from Codewarrior 10.7 and this was not the behaviour there.

Then I create a same project in CodeWarrior,when I use "Run" everything is OK.

It seems like that the programm is not be download into the MCU If I use "Debug" in CodeWarrior too .So I think that everything may be OK  if I  use "run" in S32DS . 

The problem confused me about a week,really drives me mad.

pastedImage_2.png

When I use "run" in S32DS,there is an problem.

pastedImage_3.png

pastedImage_4.png

0 Kudos
Reply
1,574 Views
FelipeGarcia
NXP Employee
NXP Employee

Hello,

 

You mentioned that this issues were not present with the same project on CodeWarrior, is that correct?

 

If so, there is a chance that something during the migration went wrong. Please check the following application note to migrate from CodeWarrior to S32DS.

https://www.nxp.com/docs/en/application-note/AN5282.pdf

 

I hope this helps.

 

Best regards,

Felipe

0 Kudos
Reply
1,574 Views
fanziyu
Contributor IV

Thanks for your help!

There is still a problem confused me that what is the difference between  "v1_5_Debug_PNE"and "v1_5_Release_PNE" and which one should be used to load into the mcu.

In Build Configuration:Debug ; Use Active;Select AutoMatically;Release .Which one should I choose?

pastedImage_1.png

0 Kudos
Reply
1,574 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi,

 

I recommend you to check the post below from a colleague:

https://mcuoneclipse.com/2012/06/01/debug-vs-release/

 

Hope it helps!

 

Best regards,

Felipe

0 Kudos
Reply
1,574 Views
fanziyu
Contributor IV

Hi,thanks for your help!

Codewarrior 10.7

I found someting new Today,

1:when I choose "run out of reset",then when PowerOn : the MCU works well  and If i don't choose run out of reset,the MCU looks like not be load the programm.

So what is the reason and is there any corresponding document?

pastedImage_1.png

2:Please look at the Register WDOG_TOVAL , I set it to 100 but WDOG_TOVALH is 100(I think the WDOG_TOVALL should be 100 ).The reset period is about 22s measured by  oscilloscope.This is really confused me.pastedImage_3.png

3:my schematic diagram;

Is there any problem with the resetting-related resistance value or capacitance value?

Is there any problem if I use the pin 8 as general I/O?

VDDX is 5V;

pastedImage_3.png

pastedImage_2.png

pastedImage_4.png

Sorry for bother you angin!

0 Kudos
Reply
1,575 Views
FelipeGarcia
NXP Employee
NXP Employee

Please check my answers below:

 

1. This could be caused because Run out of reset puts a core in run mode after reset. Please check below document.

http://cache.freescale.com/files/soft_dev_tools/doc/user_guide/CW_PA_CF_UG.pdf

 

2. If you check the Peripheral register structure for WDOG in SKEAZN84.h you could see the following:

pastedImage_10.png

As you can see TOVALH is set first when using TOVAL struct.

 

3. I think the following post could help you to use NMI pin as GPIO.

https://community.nxp.com/thread/455185 

Hope it helps!

 

Best regards,

Felipe

0 Kudos
Reply
1,574 Views
fanziyu
Contributor IV

In addition,the resister is changing when debuging.Does it mean that the watchDog is working?

pastedImage_1.png

when I pause in the debugingby pressed the "suspend" button,then press "step into" ,then the information is appeare,what  is the reason?

pastedImage_2.png

the following is the code,is there anything wrong?

pastedImage_1.png

0 Kudos
Reply
1,574 Views
fanziyu
Contributor IV

Thank for your help!

when I debug the program,the following information appears,does it mean that I load the code into the mcu successfully?

Con nection from "127.0.0.1" via 127.0.0.1
Connection from "127.0.0.1" via 127.0.0.1
Telnet server running on 127.0.0.1:51794
Searching for FreeRTOS Kernel Symbols...
pxCurrentTCB not found. FreeRTOS analysis not enabled.
Copyright 2017 P&E Microcomputer Systems,Inc.
Command Line :C:\NXP\S32DS_ARM_v2018.R1\eclipse\plugins\com.pemicro.debug.gdbjtag.pne_3.3.5.201801101746\win32\pegdbserver_console -device=NXP_KEx_S9KEAZN8M4 -startserver -singlesession -serverport=7224 -gdbmiport=6224 -interface=OPENSDA -speed=5000 -por?

CMD>RE

Initializing.
Target has been RESET and is active.
CMD>CM C:\NXP\S32DS_ARM_v2018.R1\eclipse\plugins\com.pemicro.debug.gdbjtag.pne_3.3.5.201801101746\win32\gdi\P&E\supportFiles_ARM\NXP\KEx\freescale_s9keazn8m4_pflash.arp

Initializing.
Initialized.

;version 1.00, 07/19/2013, Copyright 2013 P&E Microcomputer Systems, Inc. All rights reserved. www.pemicro.com [ke_8k_pflash_m0]

;device freescale, s9keazn8m4, pflash

;begin_cs device=$00000000, length=$00002000, ram=$20000000

Loading programming algorithm ...

WARNING - Selected .ARP file has been modified. CRC16 = $5C1E
Done.
CMD>VC
Verifying object file CRC-16 to device ranges ...
block 00000000-000000BF ...
Ok.
block 00000400-00000B47 ...
Calculated CRC-16 does not match block. (File = $3DFA, Device = $FE01)

CMD>EM

Erasing.
Module has been erased.
Reloading programming algorithm ...
done.
CMD>PM

Programming.
Processing Object File Data ...


.
Programmed.
CMD>VC
Verifying object file CRC-16 to device ranges ...
block 00000000-000000BF ...
Ok.
block 00000400-00000B47 ...
Ok.
Checksum Verification Successful. (Cumulative CRC-16=$AE06)

CMD>RE

Initializing.
Target has been RESET and is active.
Disconnected from "127.0.0.1" via 127.0.0.1
Disconnected from "127.0.0.1" via 127.0.0.1
Target Disconnected.

0 Kudos
Reply