#include "stm32f10x.h"
#include "bsp_usart1.h"
#include "bsp_adc.h"
// ADC1转换的电压值通过DMA方式到SRAM
extern __IO uint16_t ADC_ConvertedValue;
//局部变量,用于保存转换计算后的电压值
float ADC_ConvertedValueLocal;
//软件延时
void Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount--);
}
//主函数
int main(void)
{
/* USART1 config */
USART1_Config();
/* enable adc1 and config adc1 to dma mode */
ADC1_Init();
printf("\r\n ---- ADC实验(DMA传输)----\r\n");
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);
}
}
#include "bsp_usart1.h"
#include "bsp_adc.h"
// ADC1转换的电压值通过DMA方式到SRAM
extern __IO uint16_t ADC_ConvertedValue;
//局部变量,用于保存转换计算后的电压值
float ADC_ConvertedValueLocal;
//软件延时
void Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount--);
}
//主函数
int main(void)
{
/* USART1 config */
USART1_Config();
/* enable adc1 and config adc1 to dma mode */
ADC1_Init();
printf("\r\n ---- ADC实验(DMA传输)----\r\n");
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);
}
}