Skip to content

burgrp/microzig-avr-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

microzig-avr-example

MicroZig Atmel AVR example

This example demonstrates how to use interrupts in Zig to create a program that blinks an LED connected to the PA1 pin of the ATtiny412 microcontroller. The LED blinking frequency is controlled by an interrupt generated by the TCA0 timer.

Prerequisites

Before running this example, ensure you have the following:

Hardware Setup

  • Connect an LED to pin PA1 pin.
  • Connect UPDI compatible programmer to PA0 pin. You could use TinyUPDI device.

Code Explanation

  1. Import the necessary microzig module and retrieve the peripherals for the chip.

  2. Define the interrupt handler for the TCA0_LUNF interrupt. This handler toggles the state of the LED connected to PA1 and clears the overflow interrupt flag.

  3. Define the main function:

    • Configure the CPU to run at 10MHz.
    • Enable interrupts.
    • Set PA1 as an output.
    • Configure the TCA0 timer to generate interrupts.
    • Enter an idle sleep mode while waiting for interrupts.

Building and Running

git submodule update --init --recursive
cd fw
make PORT=/dev/ttyUSB0 flash

About

MicroZig Atmel AVR example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published