11 posts / 0 new
Last post
DrNick1
Offline
Last seen:4年6个月前
加入:2014-07-01 11:55
Testing watchdog

如何使用keil中的看门狗检查我的代码的正确操作。
我可以将一切一致到NMI处理程序,但是当它到达例程结束时,它执行软件重置
SetWord16(SYS_CTRL_REG, (GetWord16(SYS_CTRL_REG) & ~REMAP_ADR0) | SW_RESET );
和then it reports that it cannot start the core. I assume that the software reset has occurred but I have no way of getting control back without disconnecting the development board.

If I try to run the program outside the debugger (by stopping the debugger before it gets to this point) it still doesn't reset correctly.

那么如何使用启用WDOG运行我的程序来重置设备并在不刻录OTP的情况下检查其工作确定。是否可以?

I'm running beacon3.40.6 as a basis.

Is it straightforward to use the WDOG to force a device reset?

Device:
DrNick1
Offline
Last seen:4年6个月前
加入:2014-07-01 11:55
When the watchdog fires, it

When the watchdog fires, it eventually gets to the following line in the NMI handler routine (Beacon3.40.6)
SetWord16(SYS_CTRL_REG, (GetWord16(SYS_CTRL_REG) & ~REMAP_ADR0) | SW_RESET );
This is the instruction that resets the system. Nothing happens after this code is executed.
What does ~REMAP_ADR0 actually mean. There are 4 possible values for this given in the datasheet - the default is 00 (ROM) which implies that it will start execution from location 0 in the ROM.
My limited understanding says I should restart from the system RAM as this is where my program resides (assuming I havn't lost power or gone into deep sleep mode.)
Can anybody confirm I need to change REMAP_ADR0 away from its default setting, and when do I not need to do this?

DrNick1
Offline
Last seen:4年6个月前
加入:2014-07-01 11:55
SetWord16(SYS_CTRL_REG,

SetWord16(SYS_CTRL_REG, (GetWord16(SYS_CTRL_REG) & ~REMAP_ADR0) | SW_RESET );
这样的目的this line is to effectively make the bits corresponding to REMAP_ADR0 be zero, ie it forces the default value.
如果我改变线
setword16(sys_ctrl_reg,(getword16(sys_ctrl_reg))| sw_reset);
和make REMAP_ADR0 =0x02 (SysRAM) before this is called, then the watchdog timer expiring causes a "correct" reset and the code runs again from the beginning.
I can also still set breakpoints that work, so all seems well!

I'm still not sure what happens when I go to OTP with the watchdog. Is the default setting ok for that scenario?

MT_dialog
Offline
Last seen:2 months 3 days ago
Staff
加入:2015-06-08 11:34
Hi DrNick1,

Hi DrNick1,

Yes that right the REMAP_ADR0 is to make sure that the REMAP_ADR0 is set to the default address. The default setting should force the bootloader to run and eventualy will read from OTP.

Thanks MT_dialog

kobyfr_mag
Offline
Last seen:5 years 1 month ago
加入:2015-06-02 12:48
Hello.

Hello.
I've tried using the sdk_driver watchdog API for initializing the watchdog.
1. I have enabled watchdog//#undef CFG_WDOG
2. I've triedwdg_init(1)wdg_init(0)
My software doesn't seem to restart, even though I don't reset the watchdog:
1. It doesn't light up the LEDs again (I have an LED flashing on startup)
2. My Keil IDE debugging session doesn't hit NMI_HandlerC
添加代码来测试看门狗计数器,并将其卡在0x00FF上

MT_dialog
Offline
Last seen:2 months 3 days ago
Staff
加入:2015-06-08 11:34
Hi kobyfr_mag,

Hi kobyfr_mag,

Are you emulating a condition that eventually will crash your software and trigger the watchdog (meaning stuck in an endless loop for example)? Are you in sleep mode when using the watchdog, the watchdog resets every time you wake up from sleep. You dont have to explicitly enable it, just define it and the SDK will take care of the initializations. Also besides the fact that when in sleep mode the watchdog reloads in every wake up it also reloads in the arch_main.c file in the bottom of the main_func() function, you can comment out the below snippet and test it:

if (USE_WDOG)
wdg_reload(watchdog_default_period);

Thanks MT_dialog

kobyfr_mag
Offline
Last seen:5 years 1 month ago
加入:2015-06-02 12:48
1.是的,我想引起一个

1.是的,我想引起一个watchdog to fire, in order to test it is operational. I had no idea if I did all that is required in order to activate it.
2. I commented out arch_main.cwdg_reload(WATCHDOG_DEFAULT_PERIOD)
3. my init sequence is 3 fast LED flashes. (600 mSec total duration)
4.我无尽的循环是慢的LED闪光(应该导致看门狗在〜2秒后燃烧)
5. I loaded my program to RAM from uVision, via JLink debugger.
我允许它自由运行
7. I observed the fast LED flash sequence once, and then the slow LED flash sequence uninterrupted. ==> no SW reset ==> no watchdog occurred

Is there anything more I need to do in order for the watchdog to fire, and cause a reset?

MT_dialog
Offline
Last seen:2 months 3 days ago
Staff
加入:2015-06-08 11:34
Hi kobyfr_mag,

Hi kobyfr_mag,

I 've just noticed in post number 5, did you commented out the watchdog definition ? Try to #define CFG_WDG dont comment it out, if you comment it out the SDK will not enable it.

Please try to disable sleep mode and leave the wdg_reload(WATCHDOG_DEFAULT_PERIOD) commented, run it by using keil enviroment in a fresh template. If you do that, your code will go to the NMI_Handler().

Thanks MT_dialog

kobyfr_mag
Offline
Last seen:5 years 1 month ago
加入:2015-06-02 12:48
Thank you.

Thank you.
adding#define cgf_wdog.did the trick.
due to the而(1)我插入了,我点击了nmi_handler,看门狗每2.5秒保持射击。

陈123.
Offline
Last seen:2 months 4 weeks ago
加入:2021-01-07 01:43
Could you please tell me how
  • 你能告诉我如何为DA14580进行软件重置操作
PM_Dialog
Offline
Last seen:20 hours 24 min ago
Staff
加入:2018-02-08 11:03
Hi chen123,

Hi chen123,

Thanks for your comment. This forum thread is very old and closed, so can you please raise a new one?

Thanks, PM_Dialog