3 years, 1 month ago.

I am looking for functions read Nucleo-144 internal AD

I would like to make an analysis of the internal AD and DA on Nucleo-F767 board. Unfortunately, the used usual mbed library gives opportunity only to read % and something 16 bit value - I do not understand it's logic - can not be converted simple 12 bit original value red from the AD and write to the DA. Is there a library or program example reads and writes the 12 bit AD values directly?

1 Answer

3 years, 1 month ago.

Here is the mbed code (from analogin_api.c) used to return a 16-bit value from the 12-bit ADC conversion:

uint16_t analogin_read_u16(analogin_t *obj)
{
    uint16_t value = adc_read(obj);
    // 12-bit to 16-bit conversion
    value = ((value << 4) & (uint16_t)0xFFF0) | ((value >> 8) & (uint16_t)0x000F);
    return value;
}

A simple logical shift right (>>4) on the uint16_t value will give the original 12-bit value.

Accepted Answer

Thank you for your suggestion, it works. In the analog_loop example the DA values must be handled the same way. That caused me to confuse.

posted by László Garab 07 Nov 2016