M0AGX / LB9MG

Amateur radio and embedded systems

  • Coax relay PCB for HF antenna switching

    This is a simple board that switches 4 antennas to a single transceiver. It features SO-239 coax connectors, relays with popular footprints and flyback diodes. Unused antennas are grounded. It can be driven by virtually any controller in the shack. This design is soooo good that it got copied on …

    Read more...

  • Fast integer scaling on Cortex-M0

    Integer scaling is very common in embedded systems. For example to make human-readable values of ADC readings (correcting for gain or voltage dividers). Two operations are needed to do scaling without using floating-point numbers - multiplication and division. Cortex-M0 is a nice little beast with a single cycle integer multiplier. ARM …

    Read more...

  • Reducing FFT code size of CMSIS DSP

    CMSIS DSP is a fantastic library develeoped by ARM that provides various math primitives (like matrices, filters and FFT). It is usually my first pick when implementing signal processing on microcontrollers bacause it is highly optimized for ARM Cortex-M cores and is free. I was therefore quite surprised when my …

    Read more...

  • Debouncing buttons on EFM32 Happy Gecko

    Button bounce is always a problem for microcontrollers. There are many ways to deal with the issue. The pins can be sampled at a low frequency so that the bounce will settle between consecutive samplings. They can be low-pass filtered in software. Some approaches require the pin to be stable …

    Read more...

  • Beware of JDY-30 Bluetooth SPP modules

    Bluetooth to serial modules have been around almost forever. Just connect power, ground, RXD, TXD, maybe a config pin and you have a trivial way to transmit data wirelessly from an embedded system to a PC or Android device.

    A very common example is the HC-05 module (below):

    HC-05 Bluetooth module

    I remember …

    Read more...

  • STM32L4 I2C driver for FreeRTOS without HAL

    I2C remains a popular communication interface between MCUs and all kinds of auxiliary chips like ADCs, digipots and GPIO expanders. I had to make a simple and universal driver for an upcoming STM32L432 project to control Microchip digipots. STM32 I2C peripheral is simple enough to use without the burden of …

    Read more...

  • STM32L4 UART driver for FreeRTOS without HAL

    This is a driver for STM32L432 LPUART. It should also work with the "full" UART. The LPUART is a simple peripheral (compared to the clock tree or ADC). In this case it is easier to master the usage of a couple of registers, than use full-size HAL drivers, as they …

    Read more...

  • Generating signals with STM32L4 timer, DMA and DAC

    Generating arbitrary signals using an MCU is extremely useful. It can be used for example to play back any audio or make a modulator for a modem. The most needed MCU peripheral is of course a DAC but it also needs other peripherals to efficiently play back the samples without …

    Read more...

  • Debugging runtime memory corruption on Cortex-M

    Runtime memory corruption is one of the worst class of bugs a C/C++ application can have. I do not mean design problems like abuse of global variables but seemingly correct code clobbering memory it should never touch (for example due to runaway pointers). Compared to "regular" crashes that are …

    Read more...

  • Preserving debugging breadcrumbs across reboots in Cortex-M

    Debugging embedded systems during development even with the best tools can be hard. Certainly a good debug probe makes life easier but what do you do after the product is shipped? What if the customer complains that something strange is happening sometimes or a bug makes the device reboot but …

    Read more...