Go Down

Topic: Reset pin (Read 8683 times) previous topic - next topic

reyhane

Hello,
When we use reset pin of a microcontroller?
What does this pin do?

spycatcher2k

If you download the Datasheet, it's covered there exactly what happens
Mrs Drew
-=-
UK Based PCB Manufacturing - PM for details
I will design & code for you, but I will also charge you (PM me)
Use Google or search this site BEFORE asking!

spycatcher2k

Quote
11.1 Resetting the AVR
During reset, all I/O Registers are set to their initial values, and the program starts execution
from the Reset Vector. For the ATmega168P, the instruction placed at the Reset Vector must be
a JMP - Absolute Jump - instruction to the reset handling routine. For the ATmega48P and
ATmega88P, the instruction placed at the Reset Vector must be an RJMP - Relative Jump -
instruction to the reset handling routine. If the program never enables an interrupt source, the
Interrupt Vectors are not used, and regular program code can be placed at these locations. This
is also the case if the Reset Vector is in the Application section while the Interrupt Vectors are in
the Boot section or vice versa (ATmega88P/168P only). The circuit diagram in Figure 11-1 on
page 48 shows the reset logic. Table 29-3 on page 322 defines the electrical parameters of the
reset circuitry.
The I/O ports of the AVR are immediately reset to their initial state when a reset source goes
active. This does not require any clock source to be running.
After all reset sources have gone inactive, a delay counter is invoked, stretching the internal
reset. This allows the power to reach a stable level before normal operation starts. The time-out
period of the delay counter is defined by the user through the SUT and CKSEL Fuses. The
different selections for the delay period are presented in "Clock Sources" on page 28.
Mrs Drew
-=-
UK Based PCB Manufacturing - PM for details
I will design & code for you, but I will also charge you (PM me)
Use Google or search this site BEFORE asking!

MAS3

I bet it's also covered in your study books.
Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

krupski

Hello,
When we use reset pin of a microcontroller?
What does this pin do?
Imagine you are a microcontroller. I'll write a small program for you:

BRICKS = 100;
WHILE (BRICKS != 0) {
    PICKUP (BRICK);
    DELIVER (BRICK);
    BRICKS = (BRICKS - 1);
}


That program would make you transport 100 bricks from the "pickup" location to the "delivery" location. Each step of the process is printed on a sheet of paper for you to read.  You find the first sheet, do what it says, find the next, do that, check if "bricks" is not equal to zero, then loop around and go again.

But...... WHERE DO YOU START?

How do you know where the very first sheet of paper (the first instruction) is?

The answer is twofold:
(1) The first instruction is always in the same place and you know where this place is.
(2) When you are RESET, you always go to the special place that you know you will find the first instruction.

Even if you are half way through the program, if you are reset, you "go unconscious" and when you wake up, the first thing you do is go to the pre-defined start place.

So, all any programmer needs to do is place the starting instruction at the starting place (which is 0x0000 in the AVR).

At reset, you wake up and run straight to address 0 and read the first sheet of paper you find (and do whatever it tells you to do).

It may start the program straight away, or it may tell you "OK, now go HERE and find your next instruction".

Whatever happens, all the instructions need to be VALID, otherwise you will get confused, not know what to do and end up either doing nothing or else running in endless circles (i.e. you "CRASHED").

Makes sense?

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

reyhane


thank you, your explanation was very useful!

DrAzzy

In a more practical sense...
you use the reset pin to reset the board - either because you want the sketch to restart, or to make the bootloader run so you can upload a new sketch.

You may notice that arduino boards reset when you open the serial monitor - this is done by using the DTR pin on the serial adapter to pulse reset low (there's a clever trick they use to pulse reset low from that - search forums for "dtr reset trick" if interested in the details). This is how the IDE resets your board to upload a sketch to it - the earliest Arduino boards didn't do this, and required you to press the reset button at just the right moment in the upload process to reset the board.

At a hardware level, reset is typically connected to an external pullup (10k to Vcc), a button that connects it to ground when pressed (ie, a reset button), and the 0.1uf cap for the DTR reset trick. All of those are optional - though you should have the pullup - and you need it if doing the trick.

Since reset tri-states the pins, if you're really desperate for a USB-serial adapter and can't wait for a $1 adapter from ebay, you can use the serial adapter on an Uno/Mega/Nano board by holding reset low so the microcontroller doesn't interfere.

You should *not* reset the board from software by connecting an output to reset and driving it low. The datasheet specifically cautions against this.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

reyhane

thanks for your detailed explanation

krupski

In a more practical sense...
you use the reset pin to reset the board - either because you want the sketch to restart, or to make the bootloader run so you can upload a new sketch.

You may notice that arduino boards reset when you open the serial monitor - this is done by using the DTR pin on the serial adapter to pulse reset low (there's a clever trick they use to pulse reset low from that - search forums for "dtr reset trick" if interested in the details). This is how the IDE resets your board to upload a sketch to it - the earliest Arduino boards didn't do this, and required you to press the reset button at just the right moment in the upload process to reset the board.

At a hardware level, reset is typically connected to an external pullup (10k to Vcc), a button that connects it to ground when pressed (ie, a reset button), and the 0.1uf cap for the DTR reset trick. All of those are optional - though you should have the pullup - and you need it if doing the trick.

Since reset tri-states the pins, if you're really desperate for a USB-serial adapter and can't wait for a $1 adapter from ebay, you can use the serial adapter on an Uno/Mega/Nano board by holding reset low so the microcontroller doesn't interfere.

You should *not* reset the board from software by connecting an output to reset and driving it low. The datasheet specifically cautions against this.
Although all you've said is completely true and correct, I disagree with what you wrote because (IMHO) it doesn't answer the specific question that the OP asked.

What you wrote (all correct BTW) assumes that the reader knows what the hardware reset pin does and you explain how reset is implemented in the Arduino.

Of course, if the reader doesn't know what "reset" even does, then your explanation makes no sense to him.

By the way, I have found how to use an Arduino pin to reset itself. Simply put a 0.1 uF cap between any pin and reset. Pulling the pin low resets the AVR, and upon reset the AVR sets all port DDR bits to 0 (i.e. inputs) so that the CPU can't get stuck in an endless reset loop.

Of course, using the WDT as a reset source is probably the best way to do a software controlled reset, but other methods DO work......


Gentlemen may prefer Blondes, but Real Men prefer Redheads!

john1993

I have found how to use an Arduino pin to reset itself. Simply put a 0.1 uF cap between any pin and reset.
technically as drazzy mentioned this violates spec because reset may not be held long enough.  admittedly connecting direct to a pin does works as seen in some billions of cycles on several different platforms in tests i ran.  kinda like with 16mhz@3v probably ok for hobby use anyway.

it might be safer to run the cap from those pins to ground which will keep it low longer.  i think everyone agrees wdt is the best solution but there are rare applications where that will not do.

Go Up