Below are the configuration program
Main:
# include "sys. H"
# include "delay. H"
# include "usart. H"
# include "led. H"
# include "LCD. H"
//# include "adc. H"
# include "BSP. H"
#include
//ALIENTEK explorer STM32F407 development board experiment 18
//ADC modulus conversion experiment - library function version
//technical support: www.openedv.com
//taobao shop: http://eboard.taobao.com
//guangzhou star wing electronic technology co., LTD.
//author: accurate atomic @ ALIENTEK
Extern float AD_Value [2].
Extern volatile uint16_t ADCDualConvertedValue [2].
//float AD_Value [2].
Int main (void)
{
Under-16 adcx;
Float temp;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//set the system interrupt priority group 2
Delay_init (168);//initialization time delay function
Uart_init (9600);//initialize serial port baud rate to 115200
LED_Init ();//initialize leds
LCD_Init ();//initialize the LCD interface
BSP_Init ();
Adc1_start ();
//the Adc_Init ();//initialize the ADC
//POINT_COLOR=RED;
//LCD_ShowString (30,50,200,16,16, "Explorer STM32F4");
//LCD_ShowString (30,70,200,16,16, "ADC TEST");
//LCD_ShowString (30,90,200,16,16, "ATOM @ ALIENTEK");
//LCD_ShowString (30110200,16,16, "2014/5/6");
//POINT_COLOR=BLUE;//set the font in blue
//LCD_ShowString (30130200,16,16, "ADC1_CH6_VAL:");
//LCD_ShowString (30150200,16,16, "ADC1_CH6_VOL: 0.000 V");//in a fixed position first show decimal
While (1)
{
AD_Value [0]=(float) ADCDualConvertedValue [0]/4096 * 3.3;//get voltage value
AD_Value [1]=(float) ADCDualConvertedValue [1]/4096 * 3.3;//to get current value
Printf (" \ r \ n voltage measurement 1: % f V \ r \ n ", AD_Value [0]).
Printf (" \ r \ n voltage measurement for 2: % f V \ r \ n ", AD_Value [1]).
Delay_ms (500);
}
}
Is the following:
# include "BSP. H"
# include "sys. H"
//# include "adc. H"
/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* the INCLUDE FILES
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
Volatile uint16_t ADCDualConvertedValue [2].
Float AD_Value [2].
/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* LOCAL FUNCTION as
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
The static void HSE_SetSysClock (void);
Void ADC1_DMA_Config (void);
Void ADC1_GPIO_Config (void);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Func Name: BSP_Init
Descriptions: BSP initialization
Input para:
The Output para:
The Return value: function performs the results
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void BSP_Init (void)
{
HSE_SetSysClock ();
ADC1_GPIO_Config ();
Adc_Init ();
ADC1_DMA_Config ();
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Func Name: HSE_SetSysClock
Descriptions: STM32F407 system clock configuration: SYSCLK=168 MHZ, APB1=42 MHZ, APB2=84 MHZ
Input para: none
The Output para: none
The Return value: none
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
The static void HSE_SetSysClock (void)
{
//uint32_t pllmul;
__IO uint32_t StartUpCounter=0, HSEStartUpStatus=0;
//initialize the RCC peripherals reset state, it is a must
RCC_DeInit ();
//can make HSE, open external crystals, 8 m
RCC_HSEConfig(RCC_HSE_ON);
//wait for HSE start stable
HSEStartUpStatus=RCC_WaitForHSEStartUp ();
//HSE successfully started
If (HSEStartUpStatus==SUCCESS)
{
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --//
//can make FLASH pre access buffer
FLASH_PrefetchBufferCmd (ENABLE);
FLASH_SetLatency (FLASH_Latency_5);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --//
//AHB preassigned dividing frequency factor is set to 1, HCLK=SYSCLK
RCC_HCLKConfig (RCC_SYSCLK_Div1);
//APB2 preassigned dividing frequency factor is set to 1, PCLK2=HCLK
RCC_PCLK2Config (RCC_HCLK_Div2);
//APB1 preassigned dividing frequency factor is set to 1, PCLK1=HCLK
RCC_PCLK1Config (RCC_HCLK_Div4);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- set various frequency is mainly set up here -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --//
//set the PLL clock source to HSE, set the PLL frequency multiplication factor
//PLLCLK=8 MHZ * pllmul=168 MHZ
RCC_PLLConfig (RCC_PLLSource_HSE, 8336, 2, 4);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -//
//open the PLL
RCC_PLLCmd (ENABLE);
//wait for PLL stable
While (RCC_GetFlagStatus (RCC_FLAG_PLLRDY)==RESET)
{
}
//when PLL is stable, the PLL clock switch to a system clock SYSCLK
RCC_SYSCLKConfig (RCC_SYSCLKSource_PLLCLK);
//RCC_SYSCLKConfig (RCC_SYSCLKSource_HSE);
//read clock switching state, make sure PLLCLK was selected as system clock
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull