第一次用ADC测,刚开始选择了原子哥的例子没有DMA,上网查了查多通道采集需要DMA 然后加入了DMA后 CH1的值和以前单通道采集的值不一样 一直在2.4V左右
我感觉 使是我配置的问题。一个人在学校学这个好难 求助,下面是代码
下面是主函数
int main(void)
{
u32 SendBuff[3];
u16 adcx;
float temp;
delay_init(); //Ñóê±oˉêy3õê¼»ˉ
// NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//éèÖÃÖD¶ÏóÅÏ輶·Ö×éÎa×é2£o2λÇàÕ¼óÅÏ輶£¬2λÏìó|óÅÏ輶
uart_init(115200); //′®¿ú3õê¼»ˉÎa115200
LED_Init(); //LED¶Ë¿ú3õê¼»ˉ
LCD_Init();
Adc_Init(); //ADC3õê¼»ˉ
ADC_DMA_INIT(DMA1_Channel1,(u32)&(ADC1->DR),(u32)SendBuff,1000);//DMA1í¨μà4,íaéèÎa′®¿ú1,′æ′¢Æ÷ÎaSendBuff,3¤¶èSEND_BUF_SIZE.
POINT_COLOR=RED;//éèÖÃ×ÖìåÎaoìé«
LCD_ShowString(60,50,200,16,16,"Elite STM32");
LCD_ShowString(60,70,200,16,16,"ADC TEST");
LCD_ShowString(60,90,200,16,16,"ATOM@ALIENTEK");
LCD_ShowString(60,110,250,16,16,"2015/1/14");
//ÏÔê¾ìáê¾DÅÏ¢
POINT_COLOR=BLUE;//éèÖÃ×ÖìåÎaà¶é«
LCD_ShowString(60,130,200,16,16,"ADC_CH0_VAL:");
LCD_ShowString(60,150,300,16,16,"ADC_CH0_VOL:0.000V");
LCD_ShowString(60,170,200,16,16,"ADC_CH1_VAL:");
LCD_ShowString(60,190,300,16,16,"ADC_CH1_VOL:0.000V");
LCD_ShowString(60,210,200,16,16,"ADC_CH2_VAL:");
LCD_ShowString(60,230,300,16,16,"ADC_CH2_VOL:0.000V");
while(1)
{
adcx=Get_Adc_Average(ADC_Channel_1,10);
LCD_ShowxNum(156,130,adcx,4,16,0);//ÏÔê¾ADCμÄÖμ
temp=(float)adcx*(3.3/4096);
adcx=temp;
LCD_ShowxNum(156,150,adcx,1,16,0);//ÏÔê¾μçÑ1Öμ
temp-=adcx;
temp*=1000;
LCD_ShowxNum(172,150,temp,3,16,0X80);
LED0=1;
delay_ms(250);
adcx=Get_Adc_Average(ADC_Channel_2,10);
LCD_ShowxNum(156,170,adcx,4,16,0);//ÏÔê¾ADCμÄÖμ
temp=(float)adcx*(3.3/4096);
adcx=temp;
LCD_ShowxNum(156,190,adcx,1,16,0);//ÏÔê¾μçÑ1Öμ
temp-=adcx;
temp*=1000;
LCD_ShowxNum(172,190,temp,3,16,0X80);
LED0=0;
delay_ms(250);
adcx=Get_Adc_Average(ADC_Channel_3,10);
LCD_ShowxNum(156,210,adcx,4,16,0);//ÏÔê¾ADCμÄÖμ
temp=(float)adcx*(3.3/4096);
adcx=temp;
LCD_ShowxNum(156,230,adcx,1,16,0);//ÏÔê¾μçÑ1Öμ
temp-=adcx;
temp*=1000;
LCD_ShowxNum(172,230,temp,3,16,0X80);
LED1=1;
delay_ms(250);
LCD_ShowxNum(156,250,SendBuff[0],4,16,0);//ÏÔê¾ADCμÄÖμ
}
}
一周热门 更多>