Arm at91sam7在系统重新启动后不工作。如何强制重启?

Arm at91sam7在系统重新启动后不工作。如何强制重启?,arm,microcontroller,watchdog,Arm,Microcontroller,Watchdog,我在我的项目中使用了at91sam7s64主板,一切正常。我使用usb端口从微控制器读取和写入数据。但当windows或Linux重新启动或在待机后唤醒时,设备将不再工作,我必须从USB端口断开/连接设备。在windows i上,我正在使用hidapi库与设备通信。 在这种情况下,是否有任何方法强制at91sam7s通过监视器或其他方式重新启动自身 向上 我从闪存而不是RAM运行代码。似乎“Windows内部有两种USB重置类型。软重置只是总线上的重置信号。它重置通信管道,但已加载的驱动程序仍然

我在我的项目中使用了at91sam7s64主板,一切正常。我使用usb端口从微控制器读取和写入数据。但当windows或Linux重新启动或在待机后唤醒时,设备将不再工作,我必须从USB端口断开/连接设备。在windows i上,我正在使用hidapi库与设备通信。
在这种情况下,是否有任何方法强制at91sam7s通过监视器或其他方式重新启动自身

向上
我从闪存而不是RAM运行代码。似乎“Windows内部有两种USB重置类型。软重置只是总线上的重置信号。它重置通信管道,但已加载的驱动程序仍然处于活动状态。硬重置将在设备顶部建立整个驱动程序树。在设备侧,您看不到任何差异”

在没有USB连接的情况下,它会工作吗(如果你能以某种方式为主板供电)?尝试排除理论上的假设,即在工作期间,主板上的固件与PC上的主机操作系统进行了主动通信,这可能会在断开USB电缆时导致嵌入式系统挂起/崩溃

只是要清楚(最好在这里包含它)您是从flash而不是从RAM运行代码的,比如说,通过IDE的emulator


您还可以尝试使用JTAG(如果有)和断点进行调试,以阐明停止执行的代码段。您也可以通过打印到某些端口(如串行端口)来了解这一点。

我用来自的看门狗代码解决了这个问题

解决方案:

watchdogEnable(2000); // start the countdown

  void MyTask()
  {
    while (1) {
      if (everything_is_normal()) {
        watchdogReset();
      }
      else {
        // if things are not normal, the timer is not reset and will eventually expire
      }
    }
  }

文件夹: 看门狗

#include "config.h"
#ifdef WATCHDOG_ENABLE

#include "watchdog.h"
#include "at91sam7.h"

#define WATCHDOG_KEY (0xA5 << 24)

/**
  \defgroup Watchdog
  The Watchdog timer resets the board in the event that it's not behaving as expected.
  This is more robust than using other kinds of timers, because in the worst case, when
  your app has malfunctioned, it can still reset since it's not relying on your app to
  actually be running.

  \section Usage
  The watchdog is disabled by default.  If you want to make use of it, add the following
  line to your config.h file: \code #define WATCHDOG_ENABLE \endcode

  If you want to use it, specify the length of the countdown to watchdogEnable() and then
  periodically call watchdogReset() to reset the countdown.  If the countdown ever gets
  all the way to zero, the board will reset.

  \b Example
  \code
  watchdogEnable(2000); // start the countdown

  void MyTask()
  {
    while (1) {
      if (everything_is_normal()) {
        watchdogReset();
      }
      else {
        // if things are not normal, the timer is not reset and will eventually expire
      }
    }
  }
  \endcode
  \ingroup Core
  @{
*/

/**
  Enable the watchdog timer.
  Specify the number of milliseconds that the watchdog should wait before 
  resetting.  Remember that watchdogEnable() or watchdogDisable() can only be called
  once until the processor is reset again.

  The maximum countdown length is 16 seconds (16000 ms).
  @param millis The number of milliseconds in which a reset will occur.
*/
void watchdogEnable(int millis)
{
  int period = (millis * 256) / 1000;
  AT91C_BASE_WDTC->WDTC_WDMR =  AT91C_WDTC_WDRSTEN |        // enable reset on timeout
                                AT91C_WDTC_WDDBGHLT |       // respect debug mode
                                AT91C_WDTC_WDIDLEHLT |      // respect idle mode
                                ((period << 16 ) & AT91C_WDTC_WDD) | // delta is as wide as the period, so we can restart anytime
                                (period & AT91C_WDTC_WDV);  // set the period
}

/**
  Reset the watchdog timer countdown.
  Call watchdogEnable() first, and then call this occasionally to reset
  the watchdog countdown so that it doesn't expire.
*/
void watchdogReset()
{
  AT91C_BASE_WDTC->WDTC_WDCR = WATCHDOG_KEY | AT91C_WDTC_WDRSTT;
}

/**
  Disable the watchdog timer.
  Turn the watchdog off completely if you don't need it.

  If \b WATCHDOG_ENABLE is not defined in your config.h, this is done automatically.
*/
void watchdogDisable()
{
  AT91C_BASE_WDTC->WDTC_WDMR = AT91C_WDTC_WDDIS;
}

/** @}
*/

#endif // WATCHDOG_ENABLE

确切地说,主动沟通应该有问题。但是我怎么能触发这个,然后引起一个中断呢internally@osyan同样,您确定要闪存设备而不是从RAM/emulator会话运行吗?
#ifndef WATCHDOG_H
#define WATCHDOG_H

#ifdef __cplusplus
extern "C" {
#endif
void watchdogEnable(int millis);
void watchdogReset(void);
void watchdogDisable(void);
#ifdef __cplusplus
}
#endif
#endif // WATCHDOG_H