6 years, 8 months ago.

DAC error "Unknown DAC channel"

Hello,

I am encountering the following problem: I want to test the DAC on my STM32L053C8 discovery board (DISCO-L053C8) using the following code:

main.cpp

#include "mbed.h"
 
Serial pc(SERIAL_TX, SERIAL_RX);
AnalogOut dac(PA_4);

int main()
{  
    dac.write_u16(0);
}

It compiles without problems, but then on my Serial terminal I get the message: "Unknown DAC channel" and the DAC does not work either. I have been looking for a solution for hours now, but nothing works. I would really apreciate if somebody could help me out!

1 Answer

6 years, 8 months ago.

Hi,

There is a wrong configuration of this pin in the PeripheralPins.c file.

An Issue has been recorded but it will take some weeks before it is integrated in the mbed Library.

In the mean time you can replace your mbed library with the mbed-dev one and make the correction yourself.

The file is here: targets/TARGET_STM/TARGET_STM32L0/TARGET_DISCO_L053C8/PeripheralPins.c

Replace the line:

{PA_4, DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, DAC_OUT

with:

{PA_4, DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, DAC_OUT

Accepted Answer

Thank you very much, it works now!

posted by Marcel M 11 Jul 2017