2017-01-28 02:40 PM
hi,
I am trying to use discovery board DAC module to adjust my external led's brightness by giving different level out voltage.
I am sure that led is working on 3V, GPIOA.PA5 port also is working.
But when I run the following my DAC module, the led has no light at all. Any ideas?
void main()
{ uint32_t Ret; HAL_Init(); __HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitTypeDef GPIOInitDef; GPIOInitDef.Pin = GPIO_PIN_4; GPIOInitDef.Mode = GPIO_MODE_ANALOG; GPIOInitDef.Pull = GPIO_NOPULL; GPIOInitDef.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOA, &GPIOInitDef);DAC_HandleTypeDef DACHandleTypeStruct;
DACHandleTypeStruct.Instance = DAC; Ret = HAL_DAC_Init(&DACHandleTypeStruct);DAC_ChannelConfTypeDef DACChannelConfStruct;
DACChannelConfStruct.DAC_Trigger = DAC_TRIGGER_NONE; DACChannelConfStruct.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; Ret = HAL_DAC_ConfigChannel(&DACHandleTypeStruct,&DACChannelConfStruct, DAC_CHANNEL_1); Ret = HAL_DAC_Start(&DACHandleTypeStruct, DAC_CHANNEL_1); HAL_DAC_SetValue(&DACHandleTypeStruct, DAC_CHANNEL_1, DAC_ALIGN_12B_R, 0x0FFF);while(1)
{ ; }}
#dacSolved! Go to Solution.
2017-01-28 04:24 PM
>>Any ideas?
An inability to source sufficient current? Try using a TIM pin in PP mode using PWM
2017-01-28 04:24 PM
>>Any ideas?
An inability to source sufficient current? Try using a TIM pin in PP mode using PWM
2017-01-29 12:45 AM
Agree with Clive One, PWM has current strength while buffered DAC is intended for analog circuitry driving (and not direct LED).
2017-01-29 11:52 PM
A look at the datasheet would have revealed that the DAC output impedance is about 2 orders (buffered mode) or 5 orders of magnitude(unbuffered mode) too high.
And for dimming, analogue output is less suitable. As suggested, dimming / PWM is more energy efficient.