Bell 202 is a quite old modem standard that is still used today in amateur radio for data transmission over VHF (Packet Radio and APRS) and industrial automation (HART). It is a very simple FSK modem. The speed is limited to 1200 baud, which makes it very easy to implement on any small microcontroller. My implementation is built on top of sinewave generator code for XMEGA described in a previous post.
Making sinewaves with XMEGA DAC
The XMEGA is quite a leap from the “classic” AVRs. Some of the interesting features are the DAC and DMA. When combined, they can be used to generate all kinds of useful signals in the audio range.
This example uses the DAC, DMA, timer and event system to generate 1200 Hz and 2200 Hz sinewaves. I’ll show how to make a Bell 202 modem (think: APRS and AX.25) in another post.
Continue reading “Making sinewaves with XMEGA DAC”
XMEGA power down mode for battery powered devices
This post describes how to implement firmware-controlled device power switching on an XMEGA. I am working on a portable device that is powered from a Li-Ion cell, has an USB socket for charging, MCU, couple of LEDs and a button. I wanted to keep the design as simple as possible, so there is just one button connected to the MCU and no separate power switch. Most of the information applies equally to all AVR MCUs.
Continue reading “XMEGA power down mode for battery powered devices”
XMEGA USART driver with TX DMA
This is a quite universal, non-blocking UART driver for XMEGA. It supports both transmission (with optional DMA) and reception. Receive side can deliver callbacks whenever a complete line (terminated with \n) is received or received bytes can be retrieved one-by-one from a ringbuffer (more useful for GPS units). This driver can support multiple hardware USARTs in a single application.
Continue reading “XMEGA USART driver with TX DMA”
XMEGA high-performance SPI with DMA
I developed an universal SPI driver for XMEGA line of MCU for a battery powered device, where power efficiency was important. To get anything started on new hardware I have started with a simpler code first which uses interrupts and then I began looking at using XMEGA’s DMA controller (that was totally new to me) to improve speed and make the MCU sleep longer. This is a complete driver that can work with any kind of SPI peripherals.
It is also a nice practical introduction to DMA, because XMEGA DMA controller is one of the most simple you can find in microcontrollers (comparing let’s say to Kinetis Cortex-M), yet has all the necessary features.
Continue reading “XMEGA high-performance SPI with DMA”
XMEGA and HD44780 LCD
Character LCD are one of the easiest and cheapest way of adding output to a microcontroller system. The world of character LCDs has mainly standarized on HD44780 controller chip, which was designed to be interfaced with the rest of the system by a parallel bus, but today simple bit-banging does the job.
One of the obstacles to using HD44780 with XMEGA are different supply voltages. Displays usually require 5V, while XMEGA is 3,3V-only. Continue reading “XMEGA and HD44780 LCD”
Antenna switch & rotator controller
This is a two-in-one device. It can be set up to:
- switch 7 antenna relays from a PC over USB or using transceiver band output
- control an antenna rotator using buttons and LCD or from USB
Reliable storage of settings in EEPROM
Embedded systems often require permanent storage of some configuration parameters eg. radio channel, volume in a radio etc. All settings must be saved and read reliably, otherwise the device may become unpredictable. Imagine a variable frequency drive (an “electric motor controller”) set to a certain speed, that after a power cut reads bad data from it’s memory and overspeeds an expensive piece of moving machinery leading to physical damage.
Continue reading “Reliable storage of settings in EEPROM”
Using XMEGA hardware CRC generator for CRC-16 CCITT
CRCs are useful for checking if data received from outside or read from memory is not corrupted. This is especially important in embedded systems, as it could take just a single bit-flip to drastically change the configuration of the system. I needed to protect configuration structure of my new project when it is being saved and read from EEPROM. To make sure that the data I read from EEPROM is exactly what I have written I decided to use CRC-16 CCITT across the whole structure.
Continue reading “Using XMEGA hardware CRC generator for CRC-16 CCITT”
AVR fuses for beginners
Fuses in AVR microcontrollers have a bad reputation among beginners, because a wrong setting can lock you out of accessing the chip. With the right tools they are not scary. 🙂
Fuses are just a special name for three bytes of EEPROM-like memory (they are not “conventional OTP” fuses at all) that set the most low-level features of an AVR like:
Continue reading “AVR fuses for beginners”