Arduino provides a USART driver for treating the data as a stream, basically a never ending sequence of bytes. This follows along a tradition of sorts, basically popularized by UNIX in the 1970’s. However traditional (at the time) computers did I/O by records, blocks or packets, of data. And this is the basic operating method …
The traditional Harris 1-Wire® bus has a protocol that works well for interfacing using timer interrupts. Every bit transferred is in a single time slot that is always initiated by the microcontroller “master”. And the spacing between bits can be as long as desired, in this case the time between timer interrupts, about 1ms. As …
When considering communication between or among microcontrollers, I’ve discouraged use of the SPI interface because of its lack of a buffered interface in all but the ATmega4809 Ardruino AVR-based boards. However the handshaking protocol built into the I2C standard interface makes I2C communication a safe, reliable choice. (The I2C interface is called TWI in the …
Most I/O in a microcontroller (like in an Arduino board) consists of transactions. The microcontroller sends a command or a command plus data to a peripheral device and then, perhaps after a short delay, the device sends a response of status and data back to the microcontroller. The Arduino library tends to have only blocking …
My final dice game example for the new book uses FreeRTOS. There are three independent (non communicating) tasks, to keep things simple, rather than breaking down the game itself into multiple communicating tasks. There is the game task, a flashing light (“blinky”) task, and a background task used to measure performance, like I did with …
This book will be a catch-all for a number of topics on my mind. The family of Arduino boards. As basically revealed in previous posts, I want to address all of the AVR-based boards that are general purpose. Example programs will work on all boards (328P, 2560, 4809, or 32U4 based) even though programmed at …
Before considering the code, we need to consider what we are trying to accomplish. Commands for the TM1638 consist of a command byte followed by zero or more data bytes. Sometimes the microcontroller sends the data, other times it receives data, and in either case there is a single data wire used (MOSI and MISO …
For my next book I wanted an example program that had the need for lots of 7-segment display digits, buttons, and LEDs. I found what I wanted, at a low cost, in one of these: This has 8 7-segment (plus decimal point) digits, 8 LEDs, and 8 push buttons, and used a three-wire SPI interface. …
For those people unfamiliar with Pins.h, presumable those people who haven’t purchased Far Inside The Arduino or Far Inside The Arduino: Nano Every Supplement, this file describes a structure over the GPIO pin interface that is much more efficient than using pinMode, digitalRead, and digitalWrite. For instance, we can execute ddr.digital_2 = 1 to change …
This post was intended to compare the different general purpose Arduino boards. However I’ve been slowed down by the week of fires and hazardous air here in Oregon. I haven’t completed my investigation of the ATmega32U4 yet, and, in fact, my sample Arduino Micro, which uses this microcontroller, was delayed over a week in arrival. …