Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version: 1.0 Release Release License GPLv3

hal-avr0-rtc - AVR0 RTC Hardware Abstraction

Ask DeepWiki

The hal-avr0-rtc is a lightweight hardware abstraction library for AVR0 microcontrollers. It provides a clean interface for rtc clock initialization while hiding direct register-level interaction from higher software layers. The library is intended for projects that want to separate low-level device startup code from application logic and establish a small, reusable system layer for AVR0 targets.

Features

  • RTC clock configuration for AVR0 devices.
  • Encapsulation of low-level register access.
  • Compact and reusable API for embedded projects.
  • Foundation for layered HAL architectures.

The hal-avr0-rtc library reduces coupling by providing a focused interface for essential system services. This improves portability inside a project, keeps startup code organized, and makes higher-level modules easier to maintain.

File Structure

File Structure

hal/
└── avr0/
    └── rtc/
        ├── rtc.c
        └── rtc.h

Downloads

The library can be downloaded (zip or tar), cloned or used as submodule in a project.

Type File Description
Library zip / tar AVR0 rtc library

Using with git clone

mkdir -p ./hal/avr0
git clone https://github.com/0x007E/hal-avr0-rtc.git ./hal/avr0
mv ./hal/avr0/hal-avr0-rtc ./hal/avr0/rtc

Using as git submodule

git submodule add https://github.com/0x007E/hal-avr0-rtc.git ./hal/avr0/rtc

Programming

Additional parameters like system clock selection and prescaler can be setup in the header file. A user friendly description can be found here.

#include <avr/io.h>
#include <avr/interrupt.h> 

#include "../hal/avr0/rtc/rtc.h"

ISR(RTC_CNT_vect)
{
    RTC.INTFLAGS = RTC_OVF_bm;
}

int main(void)
{
    rtc_init();
    sei();

    while(1) { }
}

With standard settings (F_CPU@20MHz, presacler /1 and overflow 0x21) the rtc ticks around ~1ms. More details can be found in this blog entry.

Additional Information

Type Link Description
AVR0-Series pdf megaAVR® 0-series family datasheet

R. GAECHTER