AT91SAM7S64 freeze after windows sleep

Discussion about SAM7 Series and ARM7TDMI based products.

Moderator: nferre

osyan
Posts: 7
Joined: Wed Oct 08, 2014 11:22 am

AT91SAM7S64 freeze after windows sleep

Wed Oct 08, 2014 11:41 am

Hello Everyone, it's my first post. I'm writing it because I can't deal with the problem of at91sam7s64 freezing when windows wake-up after standby mode. ihave the same problem when windows restart and i have to reconnect the my header board to usb port so it start working again. I had tested my device on linux and it works fine in any situation.
any idea? :!:
how can i restart my device programmatically without plunging out/in my device?
osyan
Posts: 7
Joined: Wed Oct 08, 2014 11:22 am

Re: AT91SAM7S64 freeze after windows sleep

Wed Oct 22, 2014 8:43 am

NO IDEA?
osyan
Posts: 7
Joined: Wed Oct 08, 2014 11:22 am

Re: AT91SAM7S64 freeze after windows sleep

Fri Jul 10, 2015 4:38 pm

I solved this problem with using watchdog
Codes are from makecontroller

solution:

Code: Select all

    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
          }
        }
      }

files:
----------
watchdog.c
----------

Code: Select all

    #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

--------------
watchdog.h
--------------

Code: Select all

    #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

Return to “SAM7 ARM7TDMI MCU”

Who is online

Users browsing this forum: No registered users and 3 guests