前天STM32L052采样AD双通道切换问题,解决。
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* AdcHandle)
{
/* Get the converted value of regular channel */
uwADCxConvertedValue = HAL_ADC_GetValue(AdcHandle);
HAL_ADC_Stop_IT(&hadc);
if(CH_dp==0)
{
CH_dp=1;
ADC1->CHSELR = ADC_CHANNEL_2;
}
else
{
CH_dp=0;
ADC1->CHSELR = ADC_CHANNEL_7;
}
HAL_ADC_Start_IT(&hadc);
UART_Transmit_IT(&huart1, (uint8_t*)uwADCxConvertedValue, 4);
}
但我发现把UART_Transmit_IT(&huart1, (uint8_t*)uwADCxConvertedValue, 4);屏蔽掉就进不了AD中断
我程序,只用到AD、串口、TIM21中断,不可能出现死循环。
|