[fpc-pascal] Reversing bit-order of byte

Ludo Brands ludo.brands at free.fr
Thu May 3 10:45:01 CEST 2012


> Hi,
> 
> I'm porting a driver, originally written in C, for an LCD to be used 
> with an embedded arm-processor (STM32).
> The original driver uses SPI, my driver will use a USART in 
> synchronous 
> mode because the STM32 has no SPI for 9-bit. Unfortunately, the 
> bit-order is reversed between SPI and USART transmission.
> Does anyone knows an efficient way to reverse bit-order of a byte for 
> the arm-processor ? I'm going to look into the assembly 
> language of the 
> arm-processor, but maybe someone knows this immediately.
> For old processors like 8085 or Z80 I know how to do this, but 
> arm-assembler is new to me.
> 
> Thanks for any hints.
> 

You might also look into the RBIT instruction which does this in one cpu
cycle. See
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489c/Cihjgdi
d.html and applied to the STM32 USART
http://forum.micromouseonline.com/viewtopic.php?f=7&t=460

Ludo




More information about the fpc-pascal mailing list