1. Stm32cube Configuration 1.1 DAC configuration
1.2 TIM6 Configuration
1.3 using Cube to generate engineering programs, MDK Open softwareto add a statement on the main loop:Hal_tim_base_start (&HTIM6);HAL_DAC_START_DMA (&hdac,dac_channel_2,(uint32_t *) &samples_in[0],500,dac_align_12b_r); compile complete download to core board
2. DAC Effect Verification2.1 sine table Generation
using Matlab, a sine array of 500 points is generated. Y=ceil ((2048/2-1) *sin (0:PI*2/500:2*PI) +1200); plot (y); FID = fopen ( ' sina.txt ' , ' W ' ); fprintf (FID, '%d, ' , y); fclose (FID);2.2 Results ValidationThe sine array is entered into the MDKin the samples_in array, the oscilloscope is used to see if the sine Wave is 1KHz in duration. measured output frequency is 900Hz sine wave, analysis of the reason, is because the clock division, the same need to divide the language on the basis of 1, such as the preparation of 9, then should fill 8. Recompile, generate a sine wave with a waveform of 1KHz, as expected, as shown in.
From for notes (Wiz)
List of attachments
DAC digital-to-analog conversion based on Stm32cube