各位大神好 如题,STM32F105,DMA方式采集ADC数据,其中两路,IO口电压一样,但采集数据不一样。数据相差较大,且差值不固定。 请大神指导。 void SysInit_ADC(void) { ADC_InitTypeDef ADC_InitStructure; RCC_ADCCLKConfig(RCC_PCLK2_Div2); /* Enable ADC1*/ RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); ADC_DeInit(ADC1); /* Initialize the ADCx according to the ADC_InitStructure members */ 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 = 7; ADC_Init(ADC1,&ADC_InitStructure); ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_41Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 2, ADC_SampleTime_41Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_2, 3, ADC_SampleTime_41Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 4, ADC_SampleTime_41Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 5, ADC_SampleTime_41Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 6, ADC_SampleTime_41Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 7, ADC_SampleTime_41Cycles5); /* Enable ADC1 DMA */ ADC_DMACmd(ADC1, ENABLE); /* Enable ADC1 */ ADC_Cmd(ADC1,ENABLE); /* Enable ADC1 reset calibration register */ ADC_ResetCalibration(ADC1); /* Check the end of ADC1 reset calibration register */ while(ADC_GetResetCalibrationStatus(ADC1)); /* Start ADC1 calibration */ ADC_StartCalibration(ADC1); /* Check the end of ADC1 calibration */ while(ADC_GetCalibrationStatus(ADC1)); ADC_SoftwareStartConvCmd(ADC1, ENABLE); } void SysInit_DMA(void) { DMA_InitTypeDef DMA_InitStructure; /* Enable DMA1 clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); /* DMA1 channel1 configuration ----------------------------------------------*/ DMA_DeInit(DMA1_Channel1); DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)ADCConvertedValue; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = 7; 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(DMA1_Channel1, &DMA_InitStructure); /* Enable DMA1 channel1 */ DMA_Cmd(DMA1_Channel1, ENABLE); } //****************************************************************************************** //AD采集 //每10MS调用 //****************************************************************************************** void ADC_Scan(void) { Filter_Buf00[Filter_Pointer] = (u16)(ADCConvertedValue[0]>>2); Filter_Buf01[Filter_Pointer] = (u16)(ADCConvertedValue[1]>>2); Filter_Buf02[Filter_Pointer] = (u16)(ADCConvertedValue[2]>>2); Filter_Buf03[Filter_Pointer] = (u16)(ADCConvertedValue[3]>>2); Filter_Buf05[Filter_Pointer] = (u16)(ADCConvertedValue[4]>>2); Filter_Buf04[Filter_Pointer] = (u16)(ADCConvertedValue[5]>>2); Filter_Buf06[Filter_Pointer] = (u16)(ADCConvertedValue[6]>>2); Filter_Pointer++; if(Filter_Pointer >= 10) //去极值求平均 Filter_Remove_Extremum { Filter_Pointer = 0; Aircondition.S_InTemp = Avr_Filter(Filter_Buf0,Filter_Remove_Extremum(Filter_Buf00)); // Aircondition.S_OutTemp = Avr_Filter(Filter_Buf1,Filter_Remove_Extremum(Filter_Buf01)); Aircondition.S_Def0Temp = Avr_Filter(Filter_Buf2,Filter_Remove_Extremum(Filter_Buf02)); // Aircondition.S_LNTemp = Avr_Filter(Filter_Buf3,Filter_Remove_Extremum(Filter_Buf03)); Aircondition.S_VOL = Avr_Filter(Filter_Buf4,Filter_Remove_Extremum(Filter_Buf04)); // Aircondition.S_PTC1Temp = Avr_Filter(Filter_Buf5,Filter_Remove_Extremum(Filter_Buf05)); // Aircondition.S_PTC2Temp = Avr_Filter(Filter_Buf6,Filter_Remove_Extremum(Filter_Buf06)); // ADC_AnalogToDigtal(); } } |
使用SysTick_Config函数写延时函数,但显示SysTick_Config无法被调用,怎么解决呢?
stm32进入stop模式被莫名其妙唤醒(应该是systick)但是无法被WKUP引脚唤醒。
头文件找不到
软件为keil5,头文件未找到
通过FATFS文件系统读写SD卡创建文件可以了,但加入MSC,一直显示一个没有格式化的U盘盘符,也不能格式化,这是什么问题导致的
stm32f103汇编求助
cubemx 生成的freertos代码 在keil ac6下不能编译,有什么解决的方法吗
报错Could not determine GDB version using command: arm-none-eabi-gdb --version
stm32f107vct6配RTL8201例程
STM32F103VGT6 能代替 STM32F103VFT6 吗?
板子换过,电位器也换过,都有这个问题。引脚电压一样,应该是软件问题。但是ADC采集数据的程序都一样的,所以有点困惑