| #include "stm32f10x_lib.h" #include <stdio.h>
 extern void board_Configuration(void); extern unsigned short ADC_ConvertedValue[8];
 int main(void)
 {
 unsigned int i="0";
 unsigned short  AD_scaled_ex[8];
 unsigned short  AD_scaled[8];
   board_Configuration();while (1)
 {
 for(i=0;i<8;i++)
 {
 AD_scaled=ADC_ConvertedValue;
 if (AD_scaled != AD_scaled_ex)
 {
 printf("AD%d value = %d\r\n",i,AD_scaled);
 AD_scaled_ex = AD_scaled;
 }
 
 }
 for(i=0;i<60000000;i++);
 }
 }
 
 
 
 /* Includes ------------------------------------------------------------------*/#include "stm32f10x_lib.h"
 #include <stdio.h>
 /* Private typedef -----------------------------------------------------------*//* Private define ------------------------------------------------------------*/
 #define ADC1_DR_Address    ((u32)0x4001244C)
 /* Private macro -------------------------------------------------------------*//* Private variables ---------------------------------------------------------*/
 ADC_InitTypeDef ADC_InitStructure;
 DMA_InitTypeDef DMA_InitStructure;
 unsigned short ADC_ConvertedValue[8];
 ErrorStatus HSEStartUpStatus;
 /* Private function prototypes -----------------------------------------------*/void RCC_Configuration(void);
 void NVIC_Configuration(void);
 void GPIO_Configuration(void);
 void USART_Configuration(void);
 void DMA_Configuration(void);
 void ADC_Configuration(void);
 /* Private functions ---------------------------------------------------------*/ /******************************************************************************** Function Name  : main
 * Description    : Main program.
 * Input          : None
 * Output         : None
 * Return         : None
 *******************************************************************************/
 void board_Configuration(void)
 {
 #ifdef DEBUG
 debug();
 #endif
   /* Configure the system clocks */RCC_Configuration();
 
 /* NVIC Configuration */
 NVIC_Configuration();
   /* Configure the GPIOs */GPIO_Configuration();
 
 /* Configure the USART1 */
 USART_Configuration();
 /* Configure the DMA */
 DMA_Configuration();
 /* Configure the DMA */
 ADC_Configuration();
 }
 #ifdef  DEBUG/*******************************************************************************
 * Function Name  : assert_failed
 * Description    : Reports the name of the source file and the source line number
 *                  where the assert error has occurred.
 * Input          : - file: pointer to the source file name
 *                  - line: assert error line source number
 * Output         : None
 * Return         : None
 *******************************************************************************/
 void assert_failed(u8* file, u32 line)
 {
 /* User can add his own implementation to report the file name and line number */
   printf("\n\r Wrong parameter value detected on\r\n");printf("       file  %s\r\n", file);
 printf("       line  %d\r\n", line);
 
 /* Infinite loop */
 /* while (1)
 {
 } */
 }
 #endif
 /*******************************************************************************
 * Function Name  : DMA_Configuration
 * Description    : Configures the different system clocks.
 * Input          : None
 * Output         : None
 * Return         : None
 *******************************************************************************/
 void DMA_Configuration(void)
 {
 DMA_DeInit(DMA_Channel1);
 DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
 DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC_ConvertedValue;
 DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
 DMA_InitStructure.DMA_BufferSize = 8;
 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
 DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
 DMA_InitStructure.DMA_Priority = DMA_Priority_High;
 DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
 DMA_Init(DMA_Channel1, &DMA_InitStructure);
 
 /* Enable DMA channel1 */
 DMA_Cmd(DMA_Channel1, ENABLE);
 }
 /*******************************************************************************
 * Function Name  : ADC_Configuration
 * Description    : Configures the different system clocks.
 * Input          : None
 * Output         : None
 * Return         : None
 *******************************************************************************/
 void ADC_Configuration(void)
 {
 /* ADC1 configuration ------------------------------------------------------*/
 ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
 ADC_InitStructure.ADC_ScanConvMode = ENABLE;
 ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
 ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
 ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
 ADC_InitStructure.ADC_NbrOfChannel = 8;
 ADC_Init(ADC1, &ADC_InitStructure);
  /* ADC1 regular channel8 configuration */ ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 1, ADC_SampleTime_55Cycles5);
 /* ADC1 regular channel9 configuration */
 ADC_RegularChannelConfig(ADC1, ADC_Channel_9, 2, ADC_SampleTime_55Cycles5);
 /* ADC1 regular channel10 configuration */
 ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 3, ADC_SampleTime_55Cycles5);
 /* ADC1 regular channel11 configuration */
 ADC_RegularChannelConfig(ADC1, ADC_Channel_11, 4, ADC_SampleTime_55Cycles5);
 /* ADC1 regular channel12 configuration */
 ADC_RegularChannelConfig(ADC1, ADC_Channel_12, 5, ADC_SampleTime_55Cycles5);
 /* ADC1 regular channel13 configuration */
 ADC_RegularChannelConfig(ADC1, ADC_Channel_13, 6, ADC_SampleTime_55Cycles5);
 /* ADC1 regular channel14 configuration */
 ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 7, ADC_SampleTime_55Cycles5);
 /* ADC1 regular channel15 configuration */
 ADC_RegularChannelConfig(ADC1, ADC_Channel_15, 8, ADC_SampleTime_55Cycles5);
 /* Enable ADC1 DMA */
 ADC_DMACmd(ADC1, ENABLE);
 
 /* Enable ADC1 */
 ADC_Cmd(ADC1, ENABLE);
   /* Enable ADC1 reset calibaration register */   ADC_ResetCalibration(ADC1);
 /* Check the end of ADC1 reset calibration register */
 while(ADC_GetResetCalibrationStatus(ADC1));
   /* Start ADC1 calibaration */ADC_StartCalibration(ADC1);
 /* Check the end of ADC1 calibration */
 while(ADC_GetCalibrationStatus(ADC1));
 
 /* Start ADC1 Software Conversion */
 ADC_SoftwareStartConvCmd(ADC1, ENABLE);
 }
 /******************************************************************************** Function Name  : RCC_Configuration
 * Description    : Configures the different system clocks.
 * Input          : None
 * Output         : None
 * Return         : None
 *******************************************************************************/
 void RCC_Configuration(void)
 {
 /* RCC system reset(for debug purpose) */
 RCC_DeInit();
   /* Enable HSE */RCC_HSEConfig(RCC_HSE_ON);
   /* Wait till HSE is ready */HSEStartUpStatus = RCC_WaitForHSEStartUp();
   if(HSEStartUpStatus == SUCCESS){
 /* HCLK = SYSCLK */
 RCC_HCLKConfig(RCC_SYSCLK_Div1);
 
 /* PCLK2 = HCLK */
 RCC_PCLK2Config(RCC_HCLK_Div1);
     /* PCLK1 = HCLK/2 */RCC_PCLK1Config(RCC_HCLK_Div2);
 /* ADCCLK = PCLK2/4 */
 RCC_ADCCLKConfig(RCC_PCLK2_Div4);
     /* Flash 2 wait state */FLASH_SetLatency(FLASH_Latency_2);
 /* Enable Prefetch Buffer */
 FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
     /* PLLCLK = 8MHz * 9 = 72 MHz */RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
     /* Enable PLL */ RCC_PLLCmd(ENABLE);
     /* Wait till PLL is ready */while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
 {
 }
     /* Select PLL as system clock source */RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
     /* Wait till PLL is used as system clock source */while(RCC_GetSYSCLKSource() != 0x08)
 {
 }
 }
 
 /* Enable USART1 and GPIOA clock */
 RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE);
 /* Enable DMA clock */
 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA, ENABLE);
 /* Enable ADC1 and GPIOC clock */
 RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_GPIOC|
 RCC_APB2Periph_GPIOB, ENABLE);
 } 
 |