Tag Archives: AVR

AVR basics: using the I2C bus #5 – final thoughts

Part 1 – bit rate Part 2 – transmitting Part 3 – sending data Part 4 – receiving data Part 5 – final thoughts The I2C bus isn’t that hard to use and for most applications it’s pretty simple. However, there is a lot more depth to it than we’ve covered here. The purpose of this final post in the… Read more »

AVR basics: using the I2C bus #4 – receiving data

Part 1 – bit rate Part 2 – transmitting Part 3 – sending data Part 4 – receiving data Part 5 – final thoughts This builds on the previous two posts that dealt with the fundamentals of sending data over the I2C bus on AVR microcontrollers and then how you actually do it. Receiving is a similar process, except for… Read more »

AVR basics: using the I2C bus #3 – sending data

Part 1 – bit rate Part 2 – transmitting Part 3 – sending data Part 4 – receiving data Part 5 – final thoughts In part 2 we looked at the fundamentals of how data is transmitted over the I2C bus. Now let’s actually do it. And, as usual with AVR microcontroller stuff, it’s all about registers. As before, our… Read more »

AVR basics: using the I2C bus #2 – transmitting

Part 1 – bit rate Part 2 – transmitting Part 3 – sending data Part 4 – receiving data Part 5 – final thoughts So in the first post in this series, we looked at how to configure the bus speed for I2C. Now we’ve got that out of the way, let’s start sending stuff over the bus. The I2C… Read more »

AVR basics: SPI on the ATMEGA – Part 2

In Part 1 we got the SPI bus set up on an AVR ATMEGA328P microcontroller. Now let’s start using it. Settings pins Before we get going, we need to set up the pins for the SPI bus on the AVR (which we’re using in master mode). I’m using the ATMEGA328P here, so I’m going to define some macros to make… Read more »

AVR basics: SPI on the ATMEGA – Part 1

When it comes to getting devices to talk to each other you’re spoiled for choice. There’s good, old-fashioned serial via UARTs, I2C (which I like a lot) and what is rapidly becoming my new favourite, the Serial Peripheral Interface (SPI). So let’s take a look at that. [Quick side note: please remember I don’t claim to be an expert. I’m… Read more »

Do you know what your code’s doing?

It seems like an obvious point, but it’s sometimes handy to know what your code is up to. If you normally write code for desktop systems – and especially if you’re hacking out something that works on the command line – then it’s easy. Just pepper your program with print statements to show the state of play. (Then try to… Read more »

AVR: Battling bizarre bugs

      1 Comment on AVR: Battling bizarre bugs

Do you ever get the feeling that a compiler is acting weird just to mess with your head? That’s how it felt yesterday. I was tinkering with the code for my HexMonitor. This uses an ATMEGA328P microcontroller to read values in from an eight-bit data bus or a 16-bit address bus (selectable via a switch) and display them on a… Read more »

Debugging AVR ATMEGA code with Atmel Studio and ICE

One of the more challenging aspects of writing code for microcontrollers is not being able to liberally sprinkle your code with PRINT statements to show the state of variables and whatnot at particular moments. If you’re working with Arduino-type devices you can always fire up the Serial library and print stuff that way – back down the wire to a… Read more »

AVR basics: reading and writing GPIO pins

Once you’ve set up a pin, or a whole port’s worth of pins, as inputs or outputs, it’s time to start writing and reading values. This series is part of my learning process and I hope it will help others who, like me, are embarking on projects such as programming AVR chips. The way I learn things is to write… Read more »

AVR basics: ports and direction registers

Pretty much the first thing anyone does with a microcontroller, whether it’s a naked AVR chip or something fancy like an Arduino, is flash an LED. This series is part of my learning process and I hope it will help others who, like me, are embarking on projects such as programming AVR chips. The way I learn things is to… Read more »

AVR basics: An introduction to AVR registers and macros

It’s occurred to me that I somewhat jumped the gun when I wrote a blog post a while back about interrupts on AVR ATMEGA microcontrollers. Maybe it would be useful to take a step back. This series is part of my learning process and I hope it will help others who, like me, are embarking on projects such as programming… Read more »

AVR basics: ATMEGA 88-168-328 cheat sheets

Why is it you can never find the data sheet you need when you’re in a hurry? I’m currently exploring (or as my More Significant Other puts it, ‘twotting about with’) AVR microcontrollers. This is a natural extension of my earlier addiction to Arduinos, which are the gateway drug of the microcontroller world. Sooner or later you start feeling constrained by… Read more »

AVR basics: interrupts

      No Comments on AVR basics: interrupts

I confess I’m really enjoying delving into the secrets of AVR microprocessors. Having used Arduinos for some time now – as well as other AVR-based boards such as the mighty and wonderful Teensy – I came to the conclusion that I’m a master at µcontroller hacking. Working with ‘raw’ AVR processors quickly disabused me of that notion. The Arduino ecosphere shields you from a… Read more »