在线时间145 小时
UID2076561
注册时间2017-12-7
NXP金币31
TA的每日心情 | 衰 2024-5-28 13:38 |
---|
签到天数: 346 天 连续签到: 1 天 [LV.8]以坛为家I
金牌会员
 
- 积分
- 1552
- 最后登录
- 2025-7-15
|
本帖最后由 hu9977 于 2019-7-31 10:46 编辑
1.环境的搭建:第一次接触CW编译器,搞了两个小时,才弄好。有个地方还是有点奇怪。如下图:编译的时候source下面的文件夹会自动被添加到编译器里面。原因未知。
2.关掉看门狗:
- void wdog_disable(void)
- {
- /* First unlock the watchdog so that we can write to registers */
- wdog_unlock();
- /* Clear the WDOGE bit to disable the watchdog */
- /* WDOG_CS1 &= ~WDOG_CS1_WDOGE_MASK; */
- /*
- *((unsigned char*)0x3030) = 0x0;
- *((unsigned char*)0x3031) = 0x0;
- *((unsigned char*)0x3034) = 0xFF;
- *((unsigned char*)0x3035) = 0xFF;
- *((unsigned char*)0x3036) = 0x0;
- *((unsigned char*)0x3037) = 0x0;
- asm{ // unlock watch dog
- LDA #0xC5 // 把0XC5 放进累加器
- STA 0x3032 //把累加器里面的数据写到0x3032这个地址。
- LDA #0x20
- STA 0x3033
- LDA #0xD9
- STA 0x3032
- LDA #0x28
- STA 0x3033
- }
- */
- /* Write all 6 registers once within 128 bus cycles after unlocking */
- WDOG_CS1 = 0x20; //disabled wdog UPDATE=1
- WDOG_CS2 = 0;
- WDOG_TOVALH = 0xFF;
- WDOG_TOVALL = 0xFF;
- WDOG_WINH = 0;
- WDOG_WINL = 0;
- }
复制代码 关于解锁看门狗:
23.3.2.2 Unlocking the Watchdog
The unlock sequence is a write to the WDOG_CNTH registers of 0xC520 followed by 0xD928 within 16 bus clocks at any time after the watchdog has been configured. On completing the unlock sequence, the user must reconfigure the watchdog within 128 bus clocks; otherwise, the watchdog forces a reset to the MCU.
解锁的目的是为了能够更新配置。
关于配置看门狗:
23.3.2 Configuring the Watchdog
All watchdog control bits, timeout value, and window value are write-once after reset.This means that after a write has occurred they cannot be changed unless a reset occurs.This provides a robust mechanism to configure the watchdog and ensure that a runaway condition cannot mistakenly disable or modify the watchdog configuration after configured.
复位之后只能配置一次。是为了避免失控的情况修改看门狗的配置。
23.3.2.1 Reconfiguring the Watchdog
In some cases (such as when supporting a bootloader function), users may want to reconfigure or disable the watchdog without forcing a reset first. By setting CS1[UPDATE] to a 1 on the initial configuration of the watchdog after a reset, users can reconfigure the watchdog at any time by executing an unlock sequence. (Conversely, if CS1[UPDATE] remains 0, the only way to reconfigure the watchdog is by initiating a reset.) The unlock sequence is similar to the refresh sequence but uses different values.
设置UPDATE=1,可以软件修改配置。
留空位,后面再补其他的。
|
|