输出完全不符合实际!!!!
void DMA_Configuration(void)
{ /* DMA1 channel1 configuration ----------------------------------------------*/
DMA_DeInit(DMA1_Channel1); //DMAµÄ11ͨµÀ
DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address; //DMA¶ÔÓ¦µÄÍâÉè»ùµØÖ·
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&AD_value; //Êý¾Ý´æ´¢µØÖ·
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; //ÍâÉè×÷ΪÊý¾Ý´«ÊäµÄÀ´Ô´
DMA_InitStructure.DMA_BufferSize =2; //»º´æ´óС
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //ÍâÉèµØÖ·¼Ä´æÆ÷²»±ä
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //ÄÚ´æµØÖ·¼Ä´æÆ÷²»±ä ¶àͨµÀʹÄÜ£¿£¿
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; //ÍâÉèÊý¾Ý¿í¶È16λ
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; //16λ
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; //Ñ»·»º´æģʽ
DMA_InitStructure.DMA_Priority = DMA_Priority_High; //¸ßÓÅÏȼ¶
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //ͨµÀxûÓÐÉèÖõ½ÄÚ´æµ½ÄÚ´æ´«Êä
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
DMA_Cmd(DMA1_Channel1, ENABLE);
}
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Íⲿ´¥·¢¹Ø±Õ
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; //Êý¾ÝÓÒ¶ÔÆë
ADC_InitStructure.ADC_NbrOfChannel = 2; //¿ªÆôͨµÀÊý 1
// ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(ADC1, &ADC_InitStructure);
ADC_TempSensorVrefintCmd(ENABLE); //ʹÄÜζȴ«¸ÐÆ÷ºÍÄÚ²¿²Î¿¼µçѹͨµÀ
/* ADC1 regular channel13 configuration */
ADC_RegularChannelConfig(ADC1, ADC_Channel_13, 1, ADC_SampleTime_55Cycles5); //28.5ms ²ÉÑùʱ¼ä
ADC_RegularChannelConfig(ADC1, ADC_Channel_16, 2, ADC_SampleTime_239Cycles5);
/* 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));
}
主函数部分
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
while (1)
{
// while(USART_GetFlagStatus(USART1,USART_FLAG_TXE)==RESET);//µÈ´ý´«ÊäÍê³É·ñÔòµÚһλÊý¾ÝÈÝÒ׶ªÊ§
/* Set Clock1s to 1 every 1 second */
if (ticks++ >= 900000)
{
ticks = 0;
Clock1s = 1;
}
/* Printf message with AD value to serial port every 1 second */
if (Clock1s)
{
Clock1s = 0;
// AD_value[0] = (unsigned int)(((unsigned int)AD_value[0])*3300>>12); /* °Ñ²É¼¯µ½µÄÊýֵת»»³ÉµçѹÊý¾Ý */
AD_value[0] = AD_value[0]*3300/4096 ;
AD_value[1]=(1.43-AD_value[1]*3.3/4096)*1000/4.35 + 25;
HexToASCII(AD_value[0]);
USART1Write((uint8_t*)AsciiBuff,4);
USART1Write((uint8_t*)"\r\n",sizeof("\r\n"));
HexToASCII(AD_value[1]);
USART1Write((uint8_t*)AsciiBuff,4);
USART1Write((uint8_t*)"\r\n",sizeof("\r\n"));
}
}
|