|
【瑞萨RA4系列开发板体验】WATCHDOG功能使用
作者:大菠萝Alpha
RA4M2的WDT是一个14位递减计数器,可用于在计数器下溢时复位MCU,因为系统已失控且无法刷新WDT。此外,WDT可用于产生不可屏蔽中断或下溢中断。
- The Watchdog Timer (WDT) is a 14-bit down counter that can be used to reset the MCU when the counter underflows because the system has run out of control and is unable to refresh the WDT. In addition, the WDT can be used to generate a non-maskable interrupt or an underflow interrupt.
复制代码 首先FSP配置USART和WactchDog:
首先FSP配置USART和WactchDog:
- void hal_uart9_init()
- {
- R_SCI_UART_Open(&g_uart9_ctrl, &g_uart9_cfg);
- }
- int fputc(int ch, FILE* f)
- {
- (void) f;
- uart_tx_done = false;
- R_SCI_UART_Write(&g_uart9_ctrl, (uint8_t *)&ch, 1);
- while (uart_tx_done == false);
- return ch;
- }
- void user_uart9_callback(uart_callback_args_t* p_args)
- {
- switch (p_args->event)
- {
- case UART_EVENT_RX_CHAR:
- break;
- case UART_EVENT_TX_COMPLETE:
- uart_tx_done = true;
- break;
- default:
- break;
- }
- }
复制代码
DEBUG部分记得设置SWD,不要用JTAG,否则会跟USART9的PIN冲突。
最后点击生成代码:
最后点击生成代码:
- r_wdt_nmi_internal_callback()
复制代码 和
加入打印log的回调函数:
- printf("feed the dog!\n ");
复制代码
最后编译烧录:
- compiling common_data.c...
- compiling r_wdt.c...
- compiling r_ioport.c...
- compiling hal_data.c...
- compiling main.c...
- compiling pin_data.c...
- compiling vector_data.c...
- compiling r_sci_uart.c...
- linking...
- Program Size: Code=8712 RO-data=2392 RW-data=16 ZI-data=4216
- FromELF: creating hex file...
- ".\Objects\wdt_ra4m2.axf" - 0 Error(s), 0 Warning(s).
- Build Time Elapsed: 00:00:03
复制代码 跑起来……
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|