Hi!
I had a question some time ago (isaacavila MK22DX128VLK5 definitions) how I could make MK21DA5 based project I developed on TWR-K21D50M to run on MK22DX128VLK5.
I changed all the features as requested, however during the startup program is stuck in Reset Handler code, as it always getting watchdog interrupt just before it tries to disable watchdog timers.
I managed to generate empty project with MK22D5.h, system_MK22D5.h, system_MK22D5.c and startup_MK22D5.S (which are all almost identical to MK21DA5) and it runs OK in to the main().
Could you suggest anything I am doing wrong with MK21DA5 project so it does not run on MK22DX128VLK5.
Thank you very much,
Viktor
Hi, Victor,
Are you sure that the watchdog leads to the interrupt or reset event? after the code enters interrupt or reset, I suggest you check IPSR register in debugger, the Low 9 bits reflect the interrupt vector number, in this way, you can know the interrupt source. If it is Reset, you can check the RCM_SRSx so that you can know which leads to the Reset event.
If it is watchdog exactly which leads to reset/interrupt, you can put the the following disabling watchdog code ahead of all code. As you know that the the watchdog initial value after Reset is 0x4C0000, it is enough to reach up to the code to change setting up the watchdog generally.
Hope it can give you a clue.
BR
XiangJun Rong
#if (DISABLE_WDOG)
/* Disable the WDOG module */
/* WDOG_UNLOCK: WDOGUNLOCK=0xC520 */
WDOG->UNLOCK = (uint16_t)0xC520u; /* Key 1 */
/* WDOG_UNLOCK : WDOGUNLOCK=0xD928 */
WDOG->UNLOCK = (uint16_t)0xD928u; /* Key 2 */
/* WDOG_STCTRLH: ??=0,DISTESTWDOG=0,BYTESEL=0,TESTSEL=0,TESTWDOG=0,??=0,STNDBYEN=1,WAITEN=1,STOPEN=1,DBGEN=0,ALLOWUPDATE=1,WINEN=0,IRQRSTEN=0,CLKSRC=1,WDOGEN=0 */
WDOG->STCTRLH = (uint16_t)0x01D2u;
#endif /* (DISABLE_WDOG) */