标题: stm32 ADC采集例程 [打印本页]

作者: cjzzzy    时间: 2019-3-20 08:51
标题: stm32 ADC采集例程
#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);  
        }        
}

ADC - DMA.7z

185.55 KB, 下载次数: 21, 下载积分: 黑币 -5






欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1