Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

XMC™ Forum Discussions

User9605
Level 1
Level 1
Hello,

im looking for an example of watchdog register settings (without DAVE-apps and without XMC-lib).
I tried the implementation of the Dave3 app "WDT001" but the watchdog isn't running.
Here my try:

/* Backup Clock */
#define CLK001_WDTCLK_BACKUP 0UL
/* Standby Clock */
#define CLK001_WDTCLK_STANDBY 1UL
/* PLL Clock (fPLL) */
#define CLK001_WDTCLK_PLL 2U
#define CLK001_WDT_CLKSRC CLK001_WDTCLK_BACKUP
#define WDT001_Enable() (WDT->CTR |= (uint32_t)1 << WDT_CTR_ENB_Pos)

#define PER2_WDT 0x20000002U
/** Clear BitMask */
#define CLEAR_BITMASK 0xF0000000U
/** Reset BitMask */
#define RESET_BITMASK 0x0FFFFFFFU

//WDT-INIT

uint32_t* RCUControlReg = 0 ;
uint32_t Temp = 0 ;
/* <<>> */
SCU_RESET_TypeDef* RCUCtrlReg = SCU_RESET;
Temp = ((uint32_t)PER2_WDT & CLEAR_BITMASK) >> 28;
RCUControlReg = (uint32_t*)((uint32_t)(&RCUCtrlReg->PRSET0) + ( 0x0000000CU * Temp));
*RCUControlReg = ((uint32_t)PER2_WDT & RESET_BITMASK );

SCU_RESET->RSTCLR |= SCU_RESET_RSTCLR_RSCLR_Msk;

SCU_CLK->WDTCLKCR |= CLK001_WDTCLKDIV;
/* Select the WDT Clock source */
SCU_CLK->WDTCLKCR =(uint32_t)((uint32_t)CLK001_WDT_CLKSRC << SCU_CLK_WDTCLKCR_WDTSEL_Pos) & SCU_CLK_WDTCLKCR_WDTSEL_Msk;
/* Enable WDT Clock */
SCU_CLK->CLKSET |= (uint32_t)SCU_CLK_CLKSET_WDTCEN_Msk;

/* Configure Window Lower Bound*/
WDT->WLB = 0x0UL;
/* Configure Window Upper Bound*/
WDT->WUB = 0x4ffffffUL;

/* Configure pre-warning interrupt enable
and Service Indication pulse width*/
WDT->CTR |= (uint32_t)\
((((uint32_t)0 << WDT_CTR_SPW_Pos) & WDT_CTR_SPW_Msk) | \
((uint32_t)0 << WDT_CTR_PRE_Pos));

WDT001_Enable();


What is missing?
Regards
Bernd
0 Likes
1 Reply
jferreira
Employee
Employee
First like received 750 replies posted 500 replies posted
Hi,

Why you do not want to use XMClib or DAVE APPs? Did you try DAVE4?
Have a look to XMClib example under examples/XMC4500/WDT/WDT_FEED. You can download the standalone XMClib distribution at http://dave.infineon.com/Libraries/XMCLib/XMC_Peripheral_Library_v2.1.8.zip

Regards,
Jesus
0 Likes