All posts by admin

Atmel AVR and memory

For the past week, I have been puzzled by a problem I’ve been having with a program I’m making using an Arduino. Tonight, I solved it.

Because the Atmel AVR processor is a Harvard architecture device, program memory (Flash) and data memory (RAM) are two separate address spaces. I wanted my giant arrays to be placed in Flash, since they are never modified. In any other compiler I’ve used for embedded development, code like the following accomplishes that:

const uint8_t array[] = { ...

However, for Arduino, you have to do something like this:

#include <avr/pgmspace.h>
const uint8_t array[] PROGMEM = { ...

And then to read from it, you need to do something like this:

uint8_t data = pgm_read_byte(&array[0]);

Thanks, Atmel and Arduino, for a purely Harvard architecture processor and annoying compiler, and a few nights of confusion. At least avr-size was useful in diagnosing the problem. Also, I should probably get around to reading the AVR datasheet!

Project Completion

4/22/13 marks a milestone for me: My project at work is complete.

After today, I don’t really know what I’m going to be working on. For about two years, I’ve been on one project. Now, we are going to sign off on all of the release forms for it. After that, I might take my weekend, since I’ll have worked 15 straight days, putting in an extra 46 hours worth of time in the last week alone.

It’s going to be strange not working on this project anymore.