Tag Archives: programming

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 #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 »

ESP8266 and MicroPython: first scripts

So I have MicroPython installed on an Adafruit Huzzah ESP8266 dev board. The next step is to get it to run something. MicroPython establishes a basic filesystem using the board’s flash memory. This is handy for storing configuration and data files. And it supports a directory structure. But there are two files in particular you need to get to grips… 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: 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: 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 »

A little bit of an obsession

      No Comments on A little bit of an obsession

So I wrote this Python program to allow me to carry out certain kinds of calculations on binary numbers — you know, AND, OR, XOR and that kind of thing. It’s an absolutely essential tool for anyone who, you know, needs to NAND two 12-bit binary numbers. And happens to own a PiDP PDP-8 replica. Okay, so that’s a very… Read more »

Python on the PiDP

      No Comments on Python on the PiDP

I’m not really a C kind of person. And so when I finished building my PiDP kit, I immediately started thinking, ‘Wouldn’t it be nice to use all these switches and lights from Python?’ Because Python really is my kind of language. You can be properly expressive in it. And there’s not all that nasty business with make files. Fortunately,… Read more »