8-bit AVR Microcontrollers Reset Sources Example Project

Last modified by Microchip on 2023/11/10 11:09

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

Back to top

Connection Diagram

Project 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.

MPLAB X


Open the Project

In MPLAB X IDE, select File > Open Project.

Open Project Dialogue

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.

Open Dialog


Program the Device

Select the Make and Program Device button at the top of the MPLAB X GUI.

program button


Build the Reset Test Circuit Shown in the Schematic

Reset Circuit


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

step 9

  • 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.

step 10


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.

step 13


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.

Note: The WDT timer is set to 2 seconds.

step 14

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:

step 15

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:

step 16

Back to top

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.

Back to top

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.

Back to top