I want to know how to turn off 'watchdog' on STM32F103C8T6.

Post here all questions related to LibMaple core if you can't find a relevant section!
Post Reply
myksj1105
Posts: 95
Joined: Sun Jun 18, 2023 11:35 am
Answers: 2

I want to know how to turn off 'watchdog' on STM32F103C8T6.

Post by myksj1105 »

I want to know how to turn off 'watchdog' on STM32F103C8T6.

For example, in the case of Arduino,

Code: Select all

wdt_enable(WDTO_4S); ON
wdt_disable(); OFF
(maple board)
core : https://github.com/rogerclarkmelbourne/Arduino_STM32

Code: Select all

iwdg_prescaler WATCHDOG;
uint16_t TIMES = 10000; // 65,535
iwdg_init(IWDG_PRE_256, TIMES);
The 'WDT' function is working well when used as source code.
However, I can't turn it off.

Code: Select all

#define LIBMAPPLE_CORE //comment it for HAL based core

#define IWDG_PR_DIV_4 0x0
#define IWDG_PR_DIV_8 0x1
#define IWDG_PR_DIV_16 0x2
#define IWDG_PR_DIV_32 0x3
#define IWDG_PR_DIV_64 0x4
#define IWDG_PR_DIV_128 0x5
#define IWDG_PR_DIV_256 0x6

typedef enum iwdg_prescaler {
  IWDG_PRE_4 = IWDG_PR_DIV_4,     /**< Divide by 4 */
  IWDG_PRE_8 = IWDG_PR_DIV_8,     /**< Divide by 8 */
  IWDG_PRE_16 = IWDG_PR_DIV_16,   /**< Divide by 16 */
  IWDG_PRE_32 = IWDG_PR_DIV_32,   /**< Divide by 32 */
  IWDG_PRE_64 = IWDG_PR_DIV_64,   /**< Divide by 64 */
  IWDG_PRE_128 = IWDG_PR_DIV_128, /**< Divide by 128 */
  IWDG_PRE_256 = IWDG_PR_DIV_256  /**< Divide by 256 */
} iwdg_prescaler;

#if defined(LIBMAPPLE_CORE)
typedef struct iwdg_reg_map {
  volatile uint32_t KR;  /**< Key register. */
  volatile uint32_t PR;  /**< Prescaler register. */
  volatile uint32_t RLR; /**< Reload register. */
  volatile uint32_t SR;  /**< Status register */
} iwdg_reg_map;

#define IWDG ((struct iwdg_reg_map *)0x40003000)
#endif

void iwdg_feed(void) { IWDG->KR = 0xAAAA; }

void iwdg_init(iwdg_prescaler prescaler, uint16_t reload) {
  IWDG->KR = 0x5555;
  IWDG->PR = prescaler;
  IWDG->RLR = reload;
  // IWDG->RLR = 0xFFFF;
  IWDG->KR = 0xCCCC;
  IWDG->KR = 0xAAAA;
}

I'm using the above code.
I know how to turn it on, but I don't know how to turn it off.
Please help me.
by stevestrong » Tue Dec 31, 2024 9:37 am
According to the reference manual, once the IWDG is started it cannot be stopped except by a Reset.
Go to full post
stevestrong
Posts: 505
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 9
Location: Munich, Germany
Contact:

Re: I want to know how to turn off 'watchdog' on STM32F103C8T6.

Post by stevestrong »

According to the reference manual, once the IWDG is started it cannot be stopped except by a Reset.
Post Reply

Return to “General discussion”