|
#include "stm32f10x.h"
#include "bsp_usart.h"
#include "adc.h"
extern uint16_t ADC_ConvertedValue;
/**
* @brief 主函数
* @param 无
* @retval 无
*/
// 局部变量,用于保存转换计算后的电压值
float ADC_ConvertedValueLocal;
// 软件延时
void Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount--);
}
int main(void)
{
/*初始化USART 配置模式为 115200 8-N-1,中断接收*/
USART_Config();
//printf("欢迎使用野火STM32开发板\n\n\n\n");
ADCx_Init();
while(1)
{
ADC_ConvertedValueLocal =(float) ADC_ConvertedValue/4096*3.3; // 读取转换的AD值
printf("\r\n The current AD value = 0x%04X \r\n", ADC_ConvertedValue);
printf("\r\n The current AD value = %f V \r\n",ADC_ConvertedValueLocal);
Delay(0xffffee);
}
}
|
|