2012-09-04 07:38 PM
Hi All,
I had the DAC working using DMA to out put a sinewave continuously and it seems to have stopped working when I tried to change which timer I triggered off. After changing the timer configuration back it still doesn't work. I believe I configure everything I need to and I have code that read DAC->DOR1 out via the USART and it shows this data updating as I expect but I don't see any voltage on the DAC pin. Any ideas? Regards, Daniel #dac2012-09-04 08:13 PM
Sounds like a pin configuration or VDDA issue.
What part are we talking about? What does the pin config code look like?2012-09-05 11:05 PM
Hi Clive,
The part is a STM32F103. The pin config code is as follows: GPIO_InitTypeDef GPIO_InitStructure = { GPIO_Pin_4, GPIO_Speed_50MHz, GPIO_Mode_AIN }; GPIO_Init(GPIOA, &GPIO_InitStructure); Cheers, Daniel2012-09-05 11:53 PM
I noticed that you didn't use the GPIO configuration system in the canonical way, but checking the GPIO_InitStruct suggests that what you did should work. Quick overall DAC checklist:
Did you turn on the DAC and GPIO clocks before configuring the peripherals:RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);Did you configure the DAC:
DAC_InitStructure.DAC_Trigger = DAC_Trigger_Software;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;DAC_Init(DAC_Channel_1, &DAC_InitStructure);DAC_Cmd(DAC_Channel_1, ENABLE);Did you actually write something to the DAC:DAC_SetChannel1Data(DAC_Align_12b_R, 0x07FF);
DAC_SoftwareTriggerCmd(DAC_Channel_1, ENABLE);2012-09-06 12:31 AM
clocks
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE); DAC DAC_InitTypeDef DAC_InitStructure = { DAC_Trigger_T4_TRGO, /*DAC_Trigger*/ DAC_WaveGeneration_None, /*DAC_WaveGeneration*/ DAC_LFSRUnmask_Bit0, /*DAC_LFSRUnmask_TriangleAmplitude*/ DAC_OutputBuffer_Disable /*DAC_OutputBuffer*/ }; I have a DMA loop that writes to the DAC. When I poll the DAC->DOR1 register I see data in there changing as I expect.2012-09-06 12:44 AM
2012-09-06 12:45 AM
2012-09-06 12:46 AM
2012-09-06 03:21 AM
Hi All,
A poke round and a clean build later and the DAC is working..... Thanks for the help. Cheers, Daniel2013-01-29 10:53 AM
Hi!
board: STM32VL DiscoveryDAC1,DAC2 DORx Register = 0;Why out voltage = 60 mV?