1. BackgroundThis experiment is based on stm32f429 core board and has profound meaning for understanding stm32cube use. Using DMA for ADC sampling, with the advantage of fast, greatly reduce CPU consumption, for data acquisition system has a great advantage, especially its single 2.4MSPS sampling speed, three-way combination can achieve amazing 7.2MSPS sampling speed, for general applications can be satisfied. 2.stm32cube Configuration 2.1 The project is built in front of all and brief, here do not repeat, system clock 180MHz. 2.2 ADC parameter configuration Scan Conversion mode, when using multi-channel need to enable. continuous Conversion mode continuous conversion, when the conversion completed immediately start a new round of conversion. There are two ways in which the ADC's clock trigger is triggered by an external interrupt source such as a timer, and the other is the clock trigger of the ADC itself. Here the Timer 3 caputure Cpmpare 1 Event trigger is selected.
The ADC uses DMA to achieve data acquisition, DMA setting parameters as shown. It is important to note that the memory needs to be self-adding 1, and using FIFO, using the half-full threshold setting, in order to do "ping-pong" scheduling algorithm. Because the ADC is 12bit, half Word is used. turn on DMA interrupts. 2.3 Sampling timing pulse settingbecause the ADC uses timer 3, the timer 3 needs to be configured. If the ADC is triggered with an internal ADC clock, no configuration is required. Here the frequency is set to 500KHz, the timer clock is 180/2=90mhz,9 divided by 10MHz, then counter period is 20, sampling period 10m/20=500khz. 2.4 through Stm32cube generate source code, use MDK open project. add a statement before cycleuint16_t samples_in[512]={0}; Hal_tim_pwm_start (&htim3,tim_channel_1);HAL_ADC_START_DMA (&HADC1, (uint32_t *) &samples_in[0],512);
3. ADC Effect Verification3.1 Use the preceding section to configure the serial port baud rate 115200,DMA send enable. 3.2 on the ADC FIFO end interrupt, turn off the ADC DMA, so that it no longer work, through the serial port to the ADC acquisition of 512 sets of 16 data sent to the PC, using the Serial debugging assistant to save it to a file named "Test_sina.txt";3.3 Open the MATLAB software and create a new. m file named "TEST_GETDATA.M". Write statement:clc;clear; Sina =textread ( ' test_sina.txt ' , '%s ' ) '; % open files as characters alpha = hex2dec (Sina) '; %16 conversion to 10 decimal numbers, deposited into alpha matrix len = (Length (alpha (1,:)) +1)/2; %len = 511; for I=1:1:len s (1,i) = Alpha (1,2*i-1) +alpha (1,2*i) *256; End x = 1:len; plot (x,s);
The signal Generator has a sinusoidal signal of 1KHz, and the data collected by the ADC is restored as shown by Matlab, which is a little more than a period of sine wave. theoretical calculation: 500KHz sampling rate, the acquisition of 1KHz sine signal, can collect 1 cycles a little more, as shown in MATLAB.
to visualize the image more graphically, the next section uses the DAC to output the ADC's data in real time using the "Ping pong" scheduling algorithm.
From for notes (Wiz)
List of attachments
ADC Analog-to-digital sampling design based on Stm32cube