cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 DAC output HAL+LL naming

Hi,

HAL and LL DAC configuration structure and its parameters naming can be confusing. Reference manual claims that DAC "mode" (register ADC->MCR, bits 0..2 or 16..17) can be in one of following four combinations when not used sample and hold mode:
0 -> DAC channel2 is connected to external pin with Buffer enabled
1 -> DAC channel2 is connected to external pin and to on chip peripherals with buffer enabled

2 -> DAC channel2 is connected to external pin with buffer disabled
3 -> DAC channel2 is connected to on chip peripherals with Buffer disabled

These combinations coherent but HAL DAC init struct offers up to six conbinations (Enable/Disable buffer times Internal/External/both connections). Some of them are not accesible. I've listed following configurations:

a) - OK
DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_EXTERNAL;
Resulting configuration: 0 -> DAC channel2 is connected to external pin with Buffer enabled

b) - Misleading
DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_INTERNAL;
Resulting configuration: 1 -> DAC channel2 is connected to external pin and to on chip peripherals with buffer enabled

c) - OK
DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_BOTH;
Resulting configuration: 1 -> DAC channel2 is connected to external pin and to on chip peripherals with buffer enabled

d) - OK
DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE;
DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_EXTERNAL;
Resulting configuration: 2 -> DAC channel2 is connected to external pin with buffer disabled

e) - OK
DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE;
DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_INTERNAL;
Resulting configuration: 3 -> DAC channel2 is connected to on chip peripherals with Buffer disabled

f) - Misleading
DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE;
DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_BOTH;
Resulting configuration: 2 -> DAC channel2 is connected to external pin with buffer disabled


Also LL API have misleading parameter naming:

a) - OK
OutputBuffer = LL_DAC_OUTPUT_BUFFER_ENABLE;
OutputConnection = LL_DAC_OUTPUT_CONNECT_GPIO;
Resulting configuration: 0 -> DAC channel2 is connected to external pin with Buffer enabled

b) - Misleading
OutputBuffer = LL_DAC_OUTPUT_BUFFER_ENABLE;
OutputConnection = LL_DAC_OUTPUT_CONNECT_INTERNAL;
Resulting configuration: 1 -> DAC channel2 is connected to external pin and to on chip peripherals with buffer enabled

c) - OK
OutputBuffer = LL_DAC_OUTPUT_BUFFER_DISABLE;
OutputConnection = LL_DAC_OUTPUT_CONNECT_GPIO;
Resulting configuration: 2 -> DAC channel2 is connected to external pin with buffer disabled

d) - OK
OutputBuffer = LL_DAC_OUTPUT_BUFFER_DISABLE;
OutputConnection = LL_DAC_OUTPUT_CONNECT_INTERNAL;
Resulting configuration: 3 -> DAC channel2 is connected to on chip peripherals with Buffer disabled

You probably should enhance comment of structs
LL_DAC_InitTypeDef
DAC_ChannelConfTypeDef
to cover this confusions. Or/And change macros names. Or better change struct structure to correspond reference manual with four legal combinations.

1 ACCEPTED SOLUTION

Accepted Solutions
Imen.D
ST Employee

 

Hello @Michal Dudka ,

Thank you for having reported your feedback.

I highlighted this request (via the internal ticket number: 181777) to our development team to be analyzed.

(PS: Internal ticket number 181777 is an internal tracking number and is not accessible or usable by customers).

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

View solution in original post

2 REPLIES 2
Imen.D
ST Employee

 

Hello @Michal Dudka ,

Thank you for having reported your feedback.

I highlighted this request (via the internal ticket number: 181777) to our development team to be analyzed.

(PS: Internal ticket number 181777 is an internal tracking number and is not accessible or usable by customers).

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Imen.D
ST Employee

Hi @Michal Dudka,

About your reported cases Misleading mentioned in the description:

"b)": not a problem: connection internal requested is provided (with connection to external pin in addition. If needed, can be disconnected from pin by setting GPIO in digital mode)

"f)": indeed this is a problem because connection DAC_CHIPCONNECT_BOTH requested is not provided, connection is only on GPIO(DAC_CHIPCONNECT_EXTERNAL) 

About proposal "...change struct structure to correspond reference manual with four legal combinations": the problem is that depending of mode normal or sample & hold, these 4 combinations are different. 

The 3 parameters {mode; output buffer; connection} are managed in unitary way in drivers:

  • LL driver: only connections gpio and internal proposed (not both, since cannot be guaranteed depending on mode selected) and functions LL_DAC_ConfigOutput() and LL_DAC_SetOutputConnection() with description:  
* @note   On this STM32 series, output connection depends on output mode  
*         (normal or sample and hold) and output buffer state.  
*         - if output connection is set to internal path and output buffer  
*           is enabled (whatever output mode):  
*           output connection is also connected to GPIO pin  
*           (both connections to GPIO pin and internal path).  
*         - if output connection is set to GPIO pin, output buffer  
*           is disabled, output mode set to sample and hold:  
*           output connection is also connected to internal path  
*           (both connections to GPIO pin and internal path).
  • HAL driver: connection of both modes proposed and description missing.

We propose to update HAL DAC driver: 

  • add an assert for misleading case normal mode + buffer disabled +connection both
  • add descriptions.
When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen