dthUSART – C library for AVR microcontrollers (beta) and example code

I decided to create a simple C library for USART and AVR microcontrollers for the purpose of studying the USART serial interface.

This library is likely to be often updated. Open source code on my github:
https://github.com/xdth/AVR_dthUSART

Below is an example application. It will echo back strings received via serial at 9600 bit rate (defined in dthUSART.h), using the internal oscillator at 1 Mhz.
Read more “dthUSART – C library for AVR microcontrollers (beta) and example code”

Interfacing attiny2313 AVR with HD44780 LCD

We will use an attiny2313 AVR microcontroller to display strings on an HD44780 LCD (4-bit mode).

482 bytes of flash written. Using internal oscillator.

## Connections

+-----------------------------------+----------------+
|            HD44780 LCD            | attiny2313 MCU |
+-----------------------------------+----------------+
| PIN 1 (GND)                       |                |
| PIN 2 (+5V)                       |                |
| PIN 3 (contrast/GND)              |                |
| PIN 4 (reg select)                | PIN 2 (PD0)    |
| PIN 5 (R/W)                       | PIN 3 (PD1)    |
| PIN 6 (Enable)                    | PIN 6 (PD2)    |
| PIN 7                             |                |
| PIN 8                             |                |
| PIN 9                             |                |
| PIN 10                            |                |
| PIN 11                            | PIN 12 (PB0)   |
| PIN 12                            | PIN 13 (PB1)   |
| PIN 13                            | PIN 14 (PB2)   |
| PIN 14                            | PIN 15 (PB3)   |
| PIN 15 (220 Omhs resistor to +5V) |                |
| PIN 16 (GND)                      |                |
+-----------------------------------+----------------+

Read more “Interfacing attiny2313 AVR with HD44780 LCD”

Arduino as ISP

I prefer to develop in pure C instead of using the Arduino framework, for both learning and code size purposes. I use the Arduino board solely as an AVR programmer, using my script qAVR to flash the microcontroller.

## material
– breadboard
– jumper wires
– 10µF capacitor
– 220 ohms resistor
– LED
– Arduino
– Target microcontroller (in our example, attiny2313)

## install dev env
pacman -S avr-gcc avr-libc avrdude
wget https://raw.githubusercontent.com/xdth/qavr/master/qavr (place it in your .bin folder)

Read more “Arduino as ISP”

qAVR – Script to compile a C program, generate the hex and flash the microcontroller

This shell script will compile a C program, generate an hex file and flash it to an AVR microcontroller.

For updates, check my github repository: https://github.com/xdth/qavr


Read more “qAVR – Script to compile a C program, generate the hex and flash the microcontroller”