This post was last edited by gs001588 on 2018-1-26 03:10 STEVAL-IDB007V1 ADC Test 1 This evaluation and challenge is mainly to detect the battery power, so ADC conversion must be used. By comparing the three ADC sample programs DMA, PDM, and Polling, I think Polling can meet the requirements for single conversion. Therefore, this post only introduces and analyzes the Polling sample program. Test project path “BlueNRG-1_2 DK 2.5.0\Project\BlueNRG1_Periph_Examples\ADC\Polling\MDK-ARM\BlueNRG-1\Polling.uvprojx”, use Keil project. Open Keil project. We only care about two files “ADC_Polling_main.c” and “BlueNRG1_it.c” under “User”. “ADC_Polling_main.c” is the main program and “BlueNRG1_it.c” is the interrupt service program. Don’t worry about the others. “BlueNRG1_it.c” contains only one tick clock interrupt service, which is relatively simple. It is used for delay in the main program. Open the main program “ADC_Polling_main.c”. It contains header files, global variables for timing delay, definition of ADC initialization structure, millisecond delay function (based on tick clock), and ADC configuration. System initialization, platform identification, LED1 initialization (for flashing in the program), serial port configuration (serial port prints ADC information), tick reference clock timing 1ms initialization, ADC configuration and main loop. Let's focus on the ADC part. Take a look at the function "ADC_Configuration()". ST's consistent style is to start the corresponding clock before operating the peripherals. What do the next five parameter settings mean? Let’s take a look at them in conjunction with the comments and data sheet. “ADC_OSR_200”——Well, there is no choice. This is the only one to use for DC acquisition. “ADC_Input_AdcPin12”——Differential acquisition to eliminate common-mode interference; it is also possible to test the loop current by connecting a milliohm sampling resistor in series. “ADC_ConversionMode_Single”——Yes, a single acquisition is enough, no need for cyclic acquisition. “ADC_ReferenceVoltage_0V6”——Sampling reference voltage 0.6V “ADC_Attenuation_9dB54”——Since the acquisition range is 0 to 3.6V, the Attenuation needs to be set to 9.54 “ADC_Init()” assigns the initial structure parameters to the registers, and ignore “ADC_Calibration(ENABLE)” and “ADC_AutoOffsetUpdate(ENABLE)” AD calibration and automatic offset update for now, just use them. ADC_Init(&xADC_InitType); /* Enable auto offset correction */ ADC_Calibration(ENABLE); ADC_AutoOffsetUpdate(ENABLE);[/code] The “ADC_Cmd(ENABLE)” function starts a new ADC conversion. It is just for use. It judges the conversion completion flag. If the conversion is completed, it reads the ADC data, prints the data output to the serial port, flashes the light, delays, and starts the next conversion.
I like the style of ST. The sample program is relatively simple and the comments are sufficient. The program simulation runs at full speed. Use the serial port to check the ADC data Try to test the voltage of several points The serial port prints and displays the voltage value of each point. Compared with the multimeter's measured values of 3.298V, 1.370V, and 1.928V, the BlueNRG-1's ADC conversion accuracy is already very good, and its linearity is also pretty good. What else do you want? So far, the ADC simple test is complete. Then let's take a look at the ADC's value and voltage conversion, which is also a more interesting point of BlueNRG-1. It seems to be complicated. It is divided into 5 situations. According to the data sheet, For the Farad capacitor voltage measurement in the challenge, the ADC needs to use the “ADC_ConvertBatterySensor” mode. 928V, BlueNRG-1's ADC conversion accuracy is already very good, and the linearity is also good, what else do you want. So far, the simple ADC test is completed. Then let's understand what the ADC value and voltage conversion are like, which is also a more interesting point of BlueNRG-1, which seems to be complicated. It is divided into 5 situations. According to the data sheet, For the Farad capacitor voltage measurement in the challenge, the ADC needs to use the “ADC_ConvertBatterySensor” mode. 928V, BlueNRG-1's ADC conversion accuracy is already very good, and the linearity is also good, what else do you want. So far, the simple ADC test is completed. Then let's understand what the ADC value and voltage conversion are like, which is also a more interesting point of BlueNRG-1, which seems to be complicated. It is divided into 5 situations. According to the data sheet, For the Farad capacitor voltage measurement in the challenge, the ADC needs to use the “ADC_ConvertBatterySensor” mode.
|