AnsweredAssumed Answered

DAC problem with STM32F4

Question asked by aloisini.ennio on Mar 17, 2014
Latest reply on Mar 19, 2014 by miller.mike.003
Dear All,
I have tested the DAC example on the STM32F429 and I have understood the way using / driving the DAC on the STM32F4. I have tried to create my sample code using the STM32F429 Discovery template, but nothing happened.

Here below the code:

RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOA, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; 
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
  
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Period = 0xFF;
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; 
TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure);
TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);
TIM_Cmd(TIM6, ENABLE);
  
DAC_InitStructure.DAC_Trigger = DAC_Trigger_T6_TRGO;
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);

DAC_SetChannel1Data(DAC_Align_12b_R, 500);


I Have checked with the oscilloscope, but nothing changes.
Then I have tested the DAC_SignalGeneration and it run correctly.
Then I have tried to modify the DAC_SignalGeneration example and I have only changed this piece of code:

while (1)
  {
    /* If the User Button is pressed */
    if (KeyPressed == RESET)
    {            
      DAC_DeInit(); 


      /* select waves forms according to the Key Button status */
      if (SelectedWavesForm == 1)
      {
        /* The sine wave and the escalator wave has been selected */


        /* Escalator Wave generator ------------------------------------------*/
        DAC_Ch1_EscalatorConfig();


        /* Sine Wave generator -----------------------------------------------*/
        DAC_Ch2_SineWaveConfig();
         
      }
      else
      {
        /* The triangle wave and the noise wave has been selected */


        /* Noise Wave generator ----------------------------------------------*/
        DAC_Ch1_NoiseConfig();


        /* Triangle Wave generator -------------------------------------------*/
        DAC_Ch2_TriangleConfig();
      }
      
      KeyPressed = SET; 
    }
  }

 In the following way:

while (1)
  {
    /* If the User Button is pressed */
    if (KeyPressed == RESET)
    {            
      DAC_DeInit(); 


      /* select waves forms according to the Key Button status */
      if (SelectedWavesForm == 1)
      {
        /* The sine wave and the escalator wave has been selected */


        /* Escalator Wave generator ------------------------------------------*/
        //DAC_Ch1_EscalatorConfig();


        /* Sine Wave generator -----------------------------------------------*/
        DAC_Ch2_SineWaveConfig();
         
      }
      else
      {
        /* The triangle wave and the noise wave has been selected */


        /* Noise Wave generator ----------------------------------------------*/
        //DAC_Ch1_NoiseConfig();


        /* Triangle Wave generator -------------------------------------------*/
        //DAC_Ch2_TriangleConfig();
      }
      
      KeyPressed = SET; 
    }
  }

Sincerly I do not understand where is the problem, I have read a lot of things on internet and I have tried to do all the possible changes, but the DAC does not run with and without DMA.
Could someone help me about this problem?
Thanks!

Outcomes