標(biāo)題: stm32 ADC采集例程 [打印本頁]

作者: cjzzzy    時間: 2019-3-20 08:51
標(biāo)題: stm32 ADC采集例程
#include "stm32f10x.h"
#include "bsp_usart.h"
#include "adc.h"

extern uint16_t ADC_ConvertedValue;

/**
  * @brief  主函數(shù)
  * @param  無
  * @retval 無
  */
// 局部變量,用于保存轉(zhuǎn)換計算后的電壓值         
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開發(fā)板\n\n\n\n");
        ADCx_Init();
  while(1)
        {        
                ADC_ConvertedValueLocal =(float) ADC_ConvertedValue/4096*3.3; // 讀取轉(zhuǎn)換的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, 下載次數(shù): 21, 下載積分: 黑幣 -5






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1