STM32 stop mode & EXTI wakeup – example without HAL

Low-power modes come in handy (apart from obvious power saving) when the electromagnetic emissions of an MCU have to be reduced. For example when an MCU is placed close to antenna switching relays – you definitely do not want to receive the noise from the MCU in your HF transceiver (even if the clock frequency does not fall in an amateur band).

The trouble with low-power modes is that they are notoriously hard to debug. Often the clocks and voltage regulators have to be (re)configured. The debugger can prevent from entering into some of the modes or change their behavior. The debugger may also not be available because various clocks are stopped and supply rail lose power. Instead you have to rely on an ammeter or a simple LED to indicate which state the MCU is in.
Continue reading “STM32 stop mode & EXTI wakeup – example without HAL”

Matching STM32 hardware CRC with standard CRC-32

Hardware CRC generators come handy in embedded systems when data or code have to be validated. For example: storing settings in flash or EEPROM, receiving new firmware via a bootloader. Software implementations are either slow (when calculating the CRC directly) or need quite some memory for lookup tables. There are many CRC standards. The checksum does not necessarily have to be standards-compliant when used for internal data storage because the data will never leave the device in raw binary. However, when the data has to be exchaned with an external system it helps greatly when off the shelf libraries can be used.

I tried using the CRC peripheral available in STM32L011 and failed miserably so I had to come up with a more systematic approach to get a proper CRC-32 that is compatible with zlib, python etc.
Continue reading “Matching STM32 hardware CRC with standard CRC-32”