void ADC_Init(void)
{
ADC2_DeInit();
ADC2_Init(ADC2_CONVERSIONMODE_CONTINUOUS , ADC2_CHANNEL_10, ADC2_PRESSEL_FCPU_D18,
ADC2_EXTTRIG_TIM, DISABLE, ADC2_ALIGN_RIGHT, ADC2_SCHMITTTRIG_CHANNEL10,DISABLE);
ADC2_ITConfig(DISABLE);
ADC2_Cmd(ENABLE);
ADC2_StartConversion();
}
void Tim1_Init(void)
{
TIM1_TimeBaseInit(16,TIM1_COUNTERMODE_UP,50000,0);
TIM1_ARRPreloadConfig(ENABLE);
TIM1_ITConfig(TIM1_IT_UPDATE , ENABLE);
TIM1_Cmd(ENABLE);
}
#pragma vector=0xD
@far @interrupt void TIM1_UPD_OVF_TRG_BRK_IRQHandler(void)
{
Conversion_Value = ADC2_GetConversionValue();
Delay_ADC(0xffff);
Delay_ADC(0xffff);
ADC_Value(Conversion_Value); //把读取的值显示在LCD上
TIM1_ClearITPendingBit(TIM1_IT_UPDATE);
}
int main()
{
uint16_t Pm=0;
int cnt=0,Pm_25=0;
uint8_t PM[10]={0};
char *s=0;
CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); // 时钟配置
/*16位数据低8位*/
//SystemClock_Init(HSE_Clock);
//SPI_FLASH_Init();
USART_Configuration();
enableInterrupts();
KEY_Init();
GPIO_Init(GPIOF, GPIO_PIN_4, GPIO_MODE_OUT_PP_HIGH_FAST);
GPIO_Init(GPIOF, GPIO_PIN_5, GPIO_MODE_OUT_PP_HIGH_FAST);
GPIO_Init(GPIOC, GPIO_PIN_2, GPIO_MODE_OUT_PP_HIGH_FAST); //LCD背光
GPIO_WriteHigh(GPIOC, GPIO_PIN_2); //lcd背光灯关
GPIO_RST();
LCD_init(); // 液晶显示器初始化
LCD_first();
ADC_Init();
Tim1_Init();
while(1)
{
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
---------------------------------
已经解决了 谢谢
一周热门 更多>