2018-02-02 12:21 AM
Hi everybody,
i'm tryng to configure the IWDG but it doesn't work. i didn't find the enable bit, is there?
Can you help me?
I post my code here
void wdt_enable(void)
{ RCC -> CSR = RCC -> CSR | 0x00000001; //Enable LSI Clock while((RCC -> CSR & 0x02)==0) { //add timeout code here } IWDG -> KR = 0x0000CCCC; //Enable IWDG IWDG -> KR = 0x00005555; //Enable register access IWDG -> PR = 0x010; //Set Prescaler /16 IWDG -> RLR = 0xFFF; //Set Reload Value for 2.048 seconds while(IWDG -> SR) //Check if flags are reset { //add timeout code here } IWDG -> KR = 0x0000AAAA; //Refresh the counter}Thanks in advance
Damiano
#stm32-iwdg #iwdgSolved! Go to Solution.
2018-02-02 06:09 AM
Which register?
IWDG_KR is write only, ie. reading it back is not defined (probably results in 0).
IWDG_PR and IWDG_RLR have this note - read the IWDG chapter in RM:
Note: Reading this register returns the reload value from the VDD voltage domain. This value
may not be up to date/valid if a write operation to this register is ongoing on thisregister. For this reason the value read from this register is valid only when the RVU bitin the IWDG_SR register is reset.JW
2018-02-02 04:49 AM
'
i didn't find the enable bit, is there?'have you read the code you have written? it explicitly does so.
2018-02-02 04:56 AM
it doesn't work
How do you know?
i didn't find the enable bit
There is no enable bit - writing the key value CCCCh starts the watchdog
JW
2018-02-02 06:04 AM
because i'm using a debugger and i'm seeing that the registers have not the value written in the code
do i miss something?
Thanks
DB
2018-02-02 06:09 AM
'because i'm using a debugger and i'm seeing that the registers have not the value written in the code'
that's a different question.
'do i miss something?'
read the datasheet, as it is designed to answer this sort of questions: it has a section specifically on that.
2018-02-02 06:09 AM
Which register?
IWDG_KR is write only, ie. reading it back is not defined (probably results in 0).
IWDG_PR and IWDG_RLR have this note - read the IWDG chapter in RM:
Note: Reading this register returns the reload value from the VDD voltage domain. This value
may not be up to date/valid if a write operation to this register is ongoing on thisregister. For this reason the value read from this register is valid only when the RVU bitin the IWDG_SR register is reset.JW
2018-02-02 06:33 AM
Thanks for the help. I didn't read it!
Sorry for my mistake
Damiano