Tag Archives: I2C

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

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 a couple of slight wrinkles. The procedure is something like this: Set a start condition. Send the slave’s address across the bus along with… Read more »

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

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 focus here is on AVR microcontroller chips such as the ATMEGA328P that have a proper I2C interface. There are four main registers that concern… Read more »

AVR basics: using the I2C bus #2 – transmitting

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 bus is quite complex – at least compared to bog-standard, UART-based serial or SPI. Fortunately, Atmel has done a lot of the hard work… Read more »

AVR basics: using the I2C bus #1 – bit rate

When I first started playing around with Arduinos I quickly grew to like the I2C bus, and for a couple of good reasons. First, it was easy to use. And second, there are lots of fascinating devices out there, including displays and sensors, designed to work with it. Created by Philips Semiconductor, now NXP, the Inter-Integrated Circuit bus was designed… 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 »

Fault finding: the aha! moment

      No Comments on Fault finding: the aha! moment

Well, maybe not so much aha! More like FFS. Weird as it sounds, debugging errors is one of the things I enjoy about both coding and electronics. I’m an amateur in both fields and waste little time on planning my projects. I prefer just to delve right in. Rather than sketch out a circuit first, for example, I just get… Read more »