STM32,DMA采集一个AD数据,并通过DMA向串口发送
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include <stm32f10x.h> #include "ADC1.h" #include "DMA1.h" #include "USART1.h" #include "time.h" #include "stdio.h"
extern Байду номын сангаасint32_t SendBuff; float ADC_Received; uint32_t ADC_Received1; uint8_t ADC_Received2[11];
//printfº¯ÊýÖØж¨Ïò£¬·½±ãÔÚ³ÌÐòÖÐʹÓà int fputc(int ch, FILE *f) { USART_SendData(USART1, (unsigned char) ch);
while (!(USART1->SR & USART_FLAG_TXE));
return (ch); }
void usart_putchar(uint8_t ch) { USART_SendData(USART1,ch); while(USART_GetFlagStatus(USART1,USART_FLAG_TXE) == RESET); }
int main() { ADC1_Config(); DMA_Config(); USART1_Config(); while(1) {
// ADC_Received = (float)ADC_GetConversionValue(ADC1)*3.3/4069; // ADC_Received1 = ADC_Received * 1000000000;
ADC_Received = (float)SendBuff*3.3/4069; ADC_Received1 = ADC_Received * 1000000000;
ADC_Received2[0]=(ADC_Received1/1000000000
+
0x30);
//usart_putchar(0x2e);
extern Байду номын сангаасint32_t SendBuff; float ADC_Received; uint32_t ADC_Received1; uint8_t ADC_Received2[11];
//printfº¯ÊýÖØж¨Ïò£¬·½±ãÔÚ³ÌÐòÖÐʹÓà int fputc(int ch, FILE *f) { USART_SendData(USART1, (unsigned char) ch);
while (!(USART1->SR & USART_FLAG_TXE));
return (ch); }
void usart_putchar(uint8_t ch) { USART_SendData(USART1,ch); while(USART_GetFlagStatus(USART1,USART_FLAG_TXE) == RESET); }
int main() { ADC1_Config(); DMA_Config(); USART1_Config(); while(1) {
// ADC_Received = (float)ADC_GetConversionValue(ADC1)*3.3/4069; // ADC_Received1 = ADC_Received * 1000000000;
ADC_Received = (float)SendBuff*3.3/4069; ADC_Received1 = ADC_Received * 1000000000;
ADC_Received2[0]=(ADC_Received1/1000000000
+
0x30);
//usart_putchar(0x2e);