Closed
Description
This code appears to be used in the analogin_read_u16()
functions in all TARGET_STM32:
// 12-bit to 16-bit conversion
value = ((value << 4) & (uint16_t)0xFFF0) | ((value >> 8) & (uint16_t)0x000F);
It is supposed to convert (right-aligned) 12bit to (left-aligned) 16bit. Starting from 0x0123 it produces 0x1231. This seems like a bug, the correct value should be 0x1230.
(Regardless of what the correct value is though, it should probably not duplicate one of the original half-bytes.)