Tag Archives: SPI

Adventures with real-time clocks – part 2

The story so far: I’d been tinkering with an MCP795W20 real-time clock (RTC) chip and having a frustrating time of it. Weird things were happening. It seemed very finicky. I’d put part of the problem down to using a breadboard (still think I’m not entirely wrong about that). It turns out, however, that the biggest problem was my own stupidity…. Read more »

Adventures with real-time clocks – part 1

So I decided that I’d like to add a real-time clock (RTC) to the Zolatron project because … why not? Should be easy, I thought. Lots of people have done it. All I need is the right chip. Maybe that’s where I made my mistake. As it turned out, for some reason, I already own three copies of the Microchip… Read more »

AVR basics: control more devices using decoders

One of the issues with the Serial Peripheral Interface (SPI) bus, as many people have noted, is that it requires one Slave Select (SS) line – which means one GPIO pin on your microcontroller – for each device on the bus. That’s in addition to the three main bus lines – MOSI, MISO and SCK. This might be difficult on… 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 »