Skip to content

This repository contains an MPLAB® X project that demonstrates the basic feature of LED Toggling and Switch Press on the ATTINY1614 microcontroller using the MCU Sample Kit 1.

License

Notifications You must be signed in to change notification settings

microchip-pic-avr-examples/attiny1614-mcu-sample-kit1-get-start-mplab-mcc

Repository files navigation

Microchip Technologies Inc.

Getting Started With the tinyAVR® Microcontroller Using the MCU Sample Kit 1

This repository contains an MPLAB® X project that demonstrates the basic feature of the LED Toggling and the Switch Press on the ATTINY1614 microcontoller (MCU) using the MCU Sample Kit 1. The LED toggles at regular intervals, and the toggling rate is displayed on the serial terminal through the USB-to-UART bridge.

Related Documentation

This example is also available for the PIC18F Q71 microcontroller included in the MCU Sample Kit 1 at the following link:

More details and code examples on the PIC18F26Q71 can be found at the following links:

Software Used

Hardware Used

Concept

The system toggles the LED based on a time-out mechanism and displays the toggling frequency to the serial terminal through the USB-to-UART interface. The periodicity of the time-out will change from 500 ms to 1s, 2s, 4s, and back to 500 ms every time the user presses the switch on breadboard.

The LED toggling period is controlled by Real-Time Counter (RTC) peripheral. With every switch press, the period of RTC is updated to correspond to the selected time-out interval.

To ensure reliable detection of switch presses, a debouncing mechanism is implemented to eliminate the unwanted inputs that can cause false triggers. An interrupt is generated on the negative edge of the switch input. After the interrupt occurs, a 20 ms delay is generated using the Timer/Counter Type A 0 (TCA0). Once the TCA0 intterupt is triggered, the state of the switch is verified to determine if the pressed state is maintained.

Setup

The following peripheral configurations are set up using MPLAB Code Configurator (MCC) Melody for the ATTINY1614:

  1. TCA0:

    • Clock Select: System Clock/1024
    • Requested Period: 0.02s
    • Overflow Interrupt Enable: Enable


  2. RTC:

    • Enable RTC: Enable
    • RTC Clock Source Selection: Internal 1kHz OSC
    • Period: 0.5s
    • Overflow Interrupt Enable: Enable


  3. UART:

    • Requested Baudrate: 115200
    • Redirect Printf to UART: Enable


  4. Interrupt Manager:

    • Global Interrupt Enable: Enable


  5. Prin Grid View:


  6. Pins:


Hardware Setup

  • Place the MCU Sample Kit 1 (ATTINY1614 MCU) on the breadboard
  • MPLAB PICkit 4 allows the In-Circuit Debugger/Programmer to be used for debugging and programming the application

Note: The MCU Sample Kit 1 (ATTINY1614 MCU) does not have a built-in debugger, so the MPLAB PICkit 4 is used for programming the application.

  • Connect the MPLAB PICkit 4 to the programming header (J42) on the MCU Sample Kit 1 (ATTINY1614 MCU)

  • Connect the MPLAB PICkit to the host PC

  • Connect the user LED to pin PA4 and the switch to pin PA7 on the breadboard

  • Establish the connection between the USB-to-UART bridge and the MCU Sample Kit 1 (ATTINY1614 MCU) on the breadboard using the following connections:

    • TX to PB3
    • RX to PB2
    • GND to GND

The figure below shows the assembly used for this project.


Demo

  • Open the MPLAB Data Visualizer terminal
  • Identify the USB-to-UART bridge COM port and set the baud rate to 115200
  • The LED toggles continuously on every time-out
  • The default periodicity of the time-out is 500 ms
  • Press the switch to change the default periodicity of the time-out to 1s. Also, the LED toggling rate is displayed on the serial terminal
  • Every subsequent pressing of the switch changes the periodicity of the time-out to 1s, 2s, 4s, and back to 500 ms in cyclic order


How to Program the Microcontroller

This section demonstrates how to use the MPLAB X IDE to program an AVR® device with an Example_Project.X. This is applicable to other projects, too.

  1. Connect the board to the PC.

  2. Open the Example_Project.X project in MPLAB X IDE.

  3. Set the Example_Project.X project as main project.
    Right click the project in the Projects tab and click Set as Main Project.

  4. Clean and build the Example_Project.X project.
    Right click the Example_Project.X project and select Clean and Build.

  5. Select PICkit in the Connected Hardware Tool section of the project settings:
    Right click the project and click Properties.
    Click the arrow under the Connected Hardware Tool.
    Select PICkit (click SN), click Apply and then click OK.
    Note: Other PICkit versions can be used as well.

    Note: Make sure to enable power from PICkit.

  6. Program the project to the board.
    Right click the project and click Make and Program Device.

Menu

About

This repository contains an MPLAB® X project that demonstrates the basic feature of LED Toggling and Switch Press on the ATTINY1614 microcontroller using the MCU Sample Kit 1.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published