Microchip® Advanced Software Framework

 All Files Functions Typedefs Enumerations Enumerator Macros Groups
GPIO example for the ATmega2560 Documentation

Introduction

This example demonstrates GPIO port access, pin access, pin interrupt and pin pull up configuration.

Files:

Setup

This example is made for STK600 with two 10-pin cables in the following strap configuration:

  • PORTB <-> SWITCHES
  • PORTD <-> LEDS

Description

The example will utilize different registers for setting and reading port and pin GPIOs. These GPIOs are connected to switches and LEDs on the STK600.

In the end of the example pin change interrupts are enabled and can be tested with STK600 SW0. This will toggle LED0 from the interrupt handler. Not all megaAVR devices supports pin change interrupts, so for those this is disabled.

For the best demonstration it's recommended to run this in a debug session and single step through the different operations.

Compilation Info

This software was written for the GNU GCC for AVR.
Other compilers may or may not work.

Contact Information

For further information, visit Microchip.