Tag embedded

AVR I2C

AVRs can act as the Controller or the Target on an I2C bus. In this part, I’ll be impending the Controller side. Bitrate The first task is to configure the bitrate. According to the datasheet, the SCL frequency can be…

SFR access and unit testing

SFR access The straightforward way of accessing memory-mapped Special Function Registers (SFR) is by casting the register address to a pointer. We can also do the same in C++, potentially gaining more type safety and avoiding the standard macro pitfalls.…

AVR 16-bit Timers in C++

Low-level access There are 2 types of timer/counters typical to most 8-bit AVR microcontrollers: 8-bit (typically Timer0) and 16-bit (Timer1). Additional instances are almost identical, with the same register layouts, so it makes sense to represent them with the same…

Project Liquid

Whenever I start another microcontroller project, I find myself writing the same code all over again – setting up peripherals, looking up pin mapping, etc. Everybody does, probably. I then try to reuse the code from my older projects or…