采集AD输入电压值,并点亮小灯。但小灯无法点亮。同时,单步运行,每次adc_value的值不一样。
int main(void) { u16 i=0; uint16_t adc_value; SystemCoreClockUpdate(); Delay_Init(); USART_Printf_Init(115200); printf("SystemClk:%d\r\n",SystemCoreClock);
printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID() ); ADC_Function_Init();
printf("CalibrattionValue:%d\n", Calibrattion_Val); DMA_Tx_Init( DMA1_Channel1, (u32)&ADC1->RDATAR, (u32)TxBuf, 1024 ); DMA_Cmd( DMA1_Channel1, ENABLE ); ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 1, ADC_SampleTime_239Cycles5 ); ADC_SoftwareStartConvCmd(ADC1, ENABLE); Delay_Ms(50); ADC_SoftwareStartConvCmd(ADC1, DISABLE); GPIO_Toggle_INIT();
for(i=0; i<1024; i++) { printf( "%04d\r\n", Get_ConversionVal(TxBuf[i])); Delay_Ms(10); } while(1) { adc_value=Get_ADC_Val(ADC_Channel_1);
if( adc_value>0 )//断点处 { GPIO_WriteBit(GPIOB, GPIO_Pin_1, (i == 0) ? (i = Bit_SET) : (i = Bit_RESET)); Delay_Ms(1000); } } }