Skip to content

How do I do a Timer Overflow Interrupt? #550

Closed Answered by gregorni
gregorni asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks! After juggling a bit with some types, this is my final solution:

Code
/*
 * A program to blink the LED on pin 13 of the Arduino
 * on and of every second, using a hardware timer interrupt/
 * Interrupt Service Routine (ISR).
 * We use an overflow timer, meaning a variable is incremented
 * every set interval, and when it overflows, the ISR is triggered.
 */

#![no_std]
#![no_main]
#![feature(abi_avr_interrupt)]

use core::mem::MaybeUninit;

use arduino_hal::{
    hal::port::PB5,
    pac,
    port::{self, mode},
};
use panic_halt as _;

const CPU_CLOCKRATE: u32 = 16_000_000;
const MAX_TIMER_VALUE: u32 = 65535;
const PRESCALE_VALUE: u32 = 1024;

static mut SHARED_PERIPHERALS: MaybeU…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@djdisodo
Comment options

@gregorni
Comment options

@djdisodo
Comment options

@gregorni
Comment options

Answer selected by gregorni
@Vollbrecht
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants