2017-07-14 04:38 AM
2017-07-17 03:44 AM
And are the GPIO set properly? If you toggle the respective bits in GPIO_ODR, does the output level change?
JW
2017-07-18 06:47 PM
hi, using my F303K8 nucleo 32 board,
I just test the code of your init and
HAL_DAC_SetValue() andHAL_DAC_Start();
It works fine for both DACx and for three channels.
You may check in your stm32f3xx_hal_msp.c, is there any code looks like:
void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac)
{
GPIO_InitTypeDef GPIO_InitStruct;
if(hdac->Instance==DAC1)
{
/* Peripheral clock enable */
__HAL_RCC_DAC1_CLK_ENABLE();
/**DAC1 GPIO Configuration
PA4 ------> DAC1_OUT1
PA5 ------> DAC1_OUT2
*/
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
else if(hdac->Instance==DAC2)
{
/* Peripheral clock enable */
__HAL_RCC_DAC2_CLK_ENABLE();
/**DAC2 GPIO Configuration
PA6 ------> DAC2_OUT1
*/
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
}
It seems that, sometime, if you rework on you ioc projects, this msp part is not written or left blank.(not sure about this)
Good luck!
2017-08-22 04:43 AM
Yes, mine stm32f3xx_hal_msp.c includes these code lines.
2017-08-22 05:02 AM
yes, output stages are changing respectively, I can drive LED2 & LED3, some other pins also checked and works. DAC control register also seems to be set correctly (to my knowledge), from STM Studio it returns a value of 4128829 = DAC2: 00 00000000111111 DAC1: 00 00000000111101.