Make software reset AVR32 UC3A3256

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I run the UC3A3 on an external oscillator. I want to reset the CPU from a PC sending a reset command. I receive the command with the uC and when I do I just do this command "Reset_CPU();" But the uC hangs and notthing happends.

How would you do a software CPU reset?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Enable the Wathcdog timer with a timeout of 25-50ms for example, go to sleep and let it expire, then disable the watchdog as soon as the MCU restarts... If the watchdog timeout is too small you may be unable to disable it before it expires again.

Daniel Campora http://www.wipy.io

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have to be sure you set a WDT timeout period of longer than it takes for your uC application to start up and get to the wdt_disable(). Otherwise, your uC will restart over and over again (since you have enabled WDT to force the reset, and the WDT settings survive a reset).

In my application, I have something like:

#include "wdt.h"

int main(void)
{
     //some initialization stuff
     
     wdt_disable();

     //rest of application where 'reset_avr()' might get called
}

void reset_avr()
{
     wdt_enable(5000000); // causes the AVR to reset in 5 sec
     while(1);
}

Hope this helps!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That does reset the chip, thanks.

Just one problem, it hangs the USB connection to my PC. It might be a PC software problem thou... Perhaps the PC needs better handling of reconnecting USB.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You could also use the onchip debug system to reset the device, if you look at the CPU reset source driver in ASF, there is a function there to do soft reset.

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

You could also use the onchip debug system to reset the device, if you look at the CPU reset source driver in ASF, there is a function there to do soft reset.

Really? which is the ASF driver you are talking about?

Daniel Campora http://www.wipy.io

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

danicampora wrote:
Quote:

You could also use the onchip debug system to reset the device, if you look at the CPU reset source driver in ASF, there is a function there to do soft reset.

Really? which is the ASF driver you are talking about?

The "CPU - Reset Cause" driver in AVR Studio 5 (ASF 2.x and beyond).

The API function is reset_do_soft_reset(). Requires that the device is in supervisor mode (default mode).

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks hce. I was looking into the AVR32 studio ASF...

Daniel Campora http://www.wipy.io

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

danicampora wrote:
Thanks hce. I was looking into the AVR32 studio ASF...
I is part of the standalone ASF archive as well, latest on atmel.com is version 2.5.1 [1].

1: www.atmel.com/ASF

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the AVR32 studio ASF...

The file containing the software reset function reset_do_soft_reset() :
asf-2.5.1\avr32\drivers\cpu\avr32_reset_cause.h

attempts to include the file:
#include "sysclk.h"

which I cannot find anywhere by searching ASF

Any clues as to how to proceed?

Thanks!
- Bill

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
which I cannot find anywhere by searching ASF

common/services/clock/sysclk.h

You can grab out the CPU reset functionality quite easy though.

__builtin_mtdr(AVR32_DC, AVR32_DC_DBE_MASK);
__builtin_mtdr(AVR32_DC, AVR32_DC_RES_MASK);

This code assumes however that the clock signal to the OCD module is running, if you have disabled that clock in the power manager, then you must enable it first.

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

                Set_debug_register(AVR32_DC, AVR32_DC_DBE_MASK);
                Set_debug_register(AVR32_DC, AVR32_DC_RES_MASK);                
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You could've waited 4 more days for the 10th birthday of this thread ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...