Skip to content

STM32 AnalogIn data conversion bug #1767

Closed
@aizvorski

Description

@aizvorski

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.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions