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 provides a smaller area 32-cycle multiplier but I have not yet come across a chip that would have it. All chip makers seem to choose the faster option. Cortex-M0 however totally lacks integer division. Division is handled by library functions. A simple code like y = x * 123 / 120; gets compiled to a function call. Software division of course takes time (and energy). There is a nice hack though 🙂
Continue reading “Fast integer scaling on Cortex-M0”

Reducing FFT code size of CMSIS DSP

Fatal error: Uncaught Error: Call to a member function id() on array in /usr/home/filo/domains/ Stack trace: #0 /usr/home/filo/domains/ CrayonFormatter::format_code('', Array, Object(CrayonHighlighter)) #1 [internal function]: CrayonFormatter::delim_to_internal(Array) #2 /usr/home/filo/domains/ preg_replace_callback('#()#msi', 'CrayonFormatter...', 'arm_status arm_...') #3 /usr/home/filo/domains/ CrayonFormatter::format_mixed_code('arm_status arm_...', Object(CrayonLang), Object(CrayonHighlighter)) #4 /usr/home/filo/domains/ CrayonHighlight in /usr/home/filo/domains/ on line 36