8-bit AVR Microcontrollers Reset Sources Example Project
Objective
This project goes through several different reset conditions, Power On Reset (POR), Brown Out Reset (BOR) and Watch Dog Timer (WDT) timeout, and shows how each one works on an ATmega328PB Xplained board. Some external circuitry is shown to produce a variable voltage input but an adjustable power supply will also work.
For more details on the AVR® reset sources visit the "AVR Reset Sources" page.
Reference Materials
Required Materials
- Perfboard
- Switch
- 2 AA Batteries
- 2SC2655L IC
- AA Battery Holder
- 3.9Ω Resistor
- Test Leads
- LED
- 22 AWG Hook-Up Wire
Connection Diagram
Procedure
Attach the ATmega328PB Xplained Mini Board
Using a USB-A-male-to-Micro-B-male cable, attach the Xplained Mini to your computer. Start MPLAB X IDE. If the board has been successfully enumerated, you should see the board image come up in MPLAB X IDE as shown.
Open the Project
In MPLAB X IDE, select File > Open Project.
Navigate to the location where the project file was unzipped
Select the project folder indicated by the X in the folder name and the pressing the Open Project button.
Program the Device
Select the Make and Program Device button at the top of the MPLAB X GUI.
Build the Reset Test Circuit Shown in the Schematic
POR Test
- Pull out the USB Cable
- Make sure the External Adjustable VCC Cable’s switch is on the right side (3.2V)
- Clip The External adjustable VCC cable to the board
- Result: The orange LED will respond by flashing (0.3 ms, four times) based on the code section below because the POR reset is detected.
BOR Test
- After the POR test, slide the switch on the External Adjustable VCC Cable to the left side (2.5V)
- Slide the switch on the External Adjustable VCC Cable back to the right side (3.2V)
- Result: the orange LED will respond by flashing (0.1 ms, eight times) based on the code highlighted below because the BOR reset is detected.
WDT Test
Push the button on the board for about 1 second and then release the button. Extended delays will be triggered in the main routine, which will cause a WDT timeout.
Result: The orange LED will respond by fast flashing (0.02 ms on, 0.08 ms off, four times) at first as the WDT interrupt ISR:
Result: The orange LED will again respond by fast flashing (0.02 ms on, 0.08 ms off, four times) as the WDT reset is detected:
Analysis
The project shows three ways that a reset can occur, POR, BOR, and WDT Timeout. Each has a unique application and can all run in the same application. The code examples are just a reference to how these types of resets can be set up and implemented.
Conclusions
The project helps explain how the reset circuitry within the AVR functions and how to implement it. The code section can be reused in future applications that may require a similar reset structure. By no means is this the only way to design resets in the AVR device, this is just a simple sample project that helps explain the operation and allows you to apply your knowledge and understanding of the reset structure to a specific application.