DISCO_F407VG: can't write analog out voltage on STM32F4 PA_4 pin

Using target DISCO_F407VG, the following code does not set the analog out voltage:

AnalogOut  out(PA_4); // DAC1_OUT
out.write(1.0);

Swapping PA_5 (DAC2_OUT) for PA_4 works fine. Is this normal?

Hello Pierre,

There seems to be a bug in the mbed-os/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F407xG/TARGET_DISCO_F407VG/PeripheralPins.c file. Try to modify it as follows:

...
//*** DAC ***

MBED_WEAK const PinMap PinMap_DAC[] = {
    //{PA_4,       DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 // Connected to I2S3_WS [CS43L22_LRCK]
    {PA_4,       DAC_0, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 // Connected to I2S3_WS [CS43L22_LRCK]
    {PA_5,       DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 // Connected to SPI1_SCK [LIS302DL_SCL/SPC]
    {NC, NC, 0}
};

...

Because PinMap_DAC[] is declared as MBED_WEAK another alternative is to overwrite it in your code.

For example:

...
const PinMap PinMap_DAC[] = {
    {PA_4,       DAC_0, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 // Connected to I2S3_WS [CS43L22_LRCK]
    {PA_5,       DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 // Connected to SPI1_SCK [LIS302DL_SCL/SPC]
    {NC, NC, 0}
};    
AnalogOut  out(PA_4);
...

Best regards, Zoltan