All modern cars have an OBD2 diagnostic connector that allows reading many engine and drivetrain parameters like RPM, vehicle speed, temperatures etc.
Most of car interfaces use a special protocol translating chip like ELM327 or STN1110 to convert different vehicle protocols (that depend on the age and brand of the car) into an easier to use serial protocol with AT-commands.
I wanted to build a datalogger that would fit into a OBD2 connector. There was no space to fit my microcontroller and another chip to do protocol conversion, so I investigated and reverse-engineered the most common OBD2 protocols to be able to implement them directly on my MCU.
Continue reading “Reading OBD2 data without ELM327, part 1 – CAN”
FreeRTOS is a popular, open-source operating system that can run on a variety of microcontrollers. This post shows how to make a minimal working setup with two tasks on a new MCU without starting from a complete demo code or code generators (like Processor Expert) on an inexpensive development board FRDM-KE06Z from NXP. All examples use static memory allocation. Most of the procedures and tips mentioned here apply equally well to all Cortex-M microcontrollers.
Continue reading “FreeRTOS on Kinetis E Cortex M0+ : easy porting tutorial”
This post describes how to implement firmware-controlled device power switching on an XMEGA. I am working on a portable device that is powered from a Li-Ion cell, has an USB socket for charging, MCU, couple of LEDs and a button. I wanted to keep the design as simple as possible, so there is just one button connected to the MCU and no separate power switch. Most of the information applies equally to all AVR MCUs.
Continue reading “XMEGA power down mode for battery powered devices”
NXP Kinetis microcontrollers have an inconvenient architectural feature – split RAM. The memory is split into two areas of equal size. You can run into this issue when the size of all RAM variables (data+bss) approaches half size of available SRAM. It manifests itself with a linker error looking similar to this:
ld: region `m_data' overflowed by 132 bytes
I will use an MK22FN512 as an example, but this post applies equally to all Kinetis K-series MCUs.
Continue reading “Kinetis – relocating variables to upper SRAM”
Some time ago I have built a WiFi thermometer with a NodeMCU and a 6Ah recycled nickel-cadmium battery. WiFi is probably the least power-efficient communication methods, but I was curious how long could a NodeMCU run from a big battery pack.
It took some time to get meaningful data…
Continue reading “Practical NodeMCU endurance with a big NiCd battery pack”
This is a quite universal, non-blocking UART driver for XMEGA. It supports both transmission (with optional DMA) and reception. Receive side can deliver callbacks whenever a complete line (terminated with \n) is received or received bytes can be retrieved one-by-one from a ringbuffer (more useful for GPS units). This driver can support multiple hardware USARTs in a single application.
Continue reading “XMEGA USART driver with TX DMA”
I developed an universal SPI driver for XMEGA line of MCU for a battery powered device, where power efficiency was important. To get anything started on new hardware I have started with a simpler code first which uses interrupts and then I began looking at using XMEGA’s DMA controller (that was totally new to me) to improve speed and make the MCU sleep longer. This is a complete driver that can work with any kind of SPI peripherals.
It is also a nice practical introduction to DMA, because XMEGA DMA controller is one of the most simple you can find in microcontrollers (comparing let’s say to Kinetis Cortex-M), yet has all the necessary features.
Continue reading “XMEGA high-performance SPI with DMA”
Character LCD are one of the easiest and cheapest way of adding output to a microcontroller system. The world of character LCDs has mainly standarized on HD44780 controller chip, which was designed to be interfaced with the rest of the system by a parallel bus, but today simple bit-banging does the job.
One of the obstacles to using HD44780 with XMEGA are different supply voltages. Displays usually require 5V, while XMEGA is 3,3V-only. Continue reading “XMEGA and HD44780 LCD”
Call graphs are a visual way of showing relations between functions in a piece of code. They can be useful to analyze dependencies and to get basic understanding of a large, unfamiliar codebase. Tracing program flow can also help in finding bugs.
Continue reading “Making call graphs with GCC, egypt and cflow”
This is a two-in-one device. It can be set up to:
- switch 7 antenna relays from a PC over USB or using transceiver band output
- control an antenna rotator using buttons and LCD or from USB
Continue reading “Antenna switch & rotator controller”