我想使用STM32F4开发板由串口助手接收ADValue【】数组中的数据,可是编译下载程序后显示的明显不对呀?这是为什么??
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "lcd.h"
#include "key.h"
#include "dma.h"
#include "adc.h"
//ALIENTEK ì½Ë÷ÕßSTM32F407¿a·¢°å êμÑé23
//DMA êμÑé-¿aoˉêy°æ±¾
//¼¼êõÖ§3Ö£o
www.openedv.com
//ìÔ±|μêÆì£o
http://eboard.taobao.com
//1ãÖYêDDÇòíμç×ó¿Æ¼¼óDÏT1«Ë¾
//×÷ÕߣoÕyμãÔ-×ó @ALIENTEK
#define SEND_BUF_SIZE 100//·¢Ëíêy¾Y3¤¶è,×îoÃμèóúsizeof(TEXT_TO_SEND)+2μÄÕûêy±¶.
u16 ADValue[SEND_BUF_SIZE]; //SRAMÖD¶¨òåò»¸öêy×é
int main(void)
{
u16 i;
u8 t=0;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//éèÖÃÏμí3ÖD¶ÏóÅÏ輶·Ö×é2
delay_init(168); //3õê¼»ˉÑóê±oˉêy
uart_init(115200); //3õê¼»ˉ′®¿ú2¨ìØÂêÎa115200
LED_Init(); //3õê¼»ˉLED
Adc_Init(); //3õê¼»ˉADC
LCD_Init(); //LCD3õê¼»ˉ
KEY_Init(); //°′¼ü3õê¼»ˉ
MYDMA_Config(DMA2_Stream4,DMA_Channel_0,(u32)&ADC1->DR,(u32)ADValue,6);//DMA2,STEAM4,CH0,íaéèÎa′®¿ú1,′æ′¢Æ÷ÎaADValue,3¤¶èÎa:SEND_BUF_SIZE.
ADValue[6]=0x0c01;
ADValue[7]=0x04cd;
ADValue[8]=0x0101;
ADValue[9]=0x0c01;
ADValue[10]=0x04cd;
ADValue[11]=0x0101;
ADValue[12]=0x0081;
ADValue[13]=0x0180;
ADValue[14]=0xba88;
ADValue[15]=0x0100;
ADValue[16]=0x0066;
ADValue[17]=0x0000;
ADValue[18]=0x6000;
ADValue[19]=0x805d;
ADValue[20]=0x0101;
ADValue[21]=0x58a2;
ADValue[22]=0x5630;
ADValue[23]=0x1580;
ADValue[24]=0x4153;
ADValue[25]=0x504d;
ADValue[26]=0x454c;
ADValue[27]=0x2e44;
ADValue[28]=0x4156;
ADValue[29]=0x554c;
ADValue[30]=0x2e45;
ADValue[31]=0x454d;
ADValue[32]=0x5353;
ADValue[33]=0x4741;
ADValue[34]=0x8245;
ADValue[35]=0x0302;
ADValue[36]=0x83e8;
ADValue[37]=0x0004;
ADValue[38]=0x0000;
ADValue[39]=0x8501;
ADValue[40]=0x0101;
ADValue[41]=0x3087;
while(1)
{
t=KEY_Scan(0);
if(t==KEY0_PRES) //KEY0°′ÏÂ
{
USART_Cmd(USART1, ENABLE);//ê1Äü′®¿ú1
ADC_SoftwareStartConv(ADC1); //ê1Äüèí¼tÆô¶ˉADC1
ADC_DMACmd(ADC1,ENABLE); //ê1ÄüADC-DMA′«êä
MYDMA_Enable(DMA2_Stream4,SEND_BUF_SIZE); //¿aê¼ò»′ÎDMA′«ê䣡
USART_SendData(USART1, ADValue[6]);
USART_SendData(USART1, ADValue[7]);
printf("ADValue[6]");
printf("ADValue[7]");
printf("ADValue[8]");
printf("ADValue[9]");
printf("ADValue[10]");
printf("ADValue[11]");
printf("ADValue[12]");
printf("ADValue[13]");
printf("ADValue[14]");
printf("ADValue[15]");
printf("ADValue[16]");
printf("ADValue[17]");
printf("ADValue[18]");
printf("ADValue[19]");
printf("ADValue[20]");
printf("ADValue[21]");
printf("ADValue[22]");
printf("ADValue[23]");
printf("ADValue[24]");
printf("ADValue[25]");
printf("ADValue[26]");
printf("ADValue[27]");
printf("ADValue[28]");
printf("ADValue[29]");
printf("ADValue[30]");
printf("ADValue[31]");
printf("ADValue[32]");
printf("ADValue[33]");
printf("ADValue[34]");
printf("ADValue[35]");
printf("ADValue[36]");
printf("ADValue[37]");
printf("ADValue[38]");
printf("ADValue[39]");
printf("ADValue[40]");
printf("ADValue[41]");
printf("ADValue[0]");
printf("ADValue[1]");
printf("ADValue[2]");
printf("ADValue[3]");
printf("ADValue[4]");
printf("ADValue[5]");
//μè′yDMA′«êäíê3飬′Ëê±ÎòÃÇà′×öáííaò»D©ê£¬μãμÆ
//êμ¼êó|óÃÖD£¬′«êäêy¾YÆú¼ä£¬¿éòÔÖ′DDáííaμÄèÎÎñ
while(1)
{
if(DMA_GetFlagStatus(DMA2_Stream4,DMA_FLAG_TCIF4)!=RESET)//μè′yDMA2_Steam4′«êäíê3é
{
DMA_ClearFlag(DMA2_Stream4,DMA_FLAG_TCIF4);//Çå3yDMA2_Steam4′«êäíê3é±êÖ¾
break;
}
}
}
i++;
delay_ms(10);
if(i==20)
{
LED0=!LED0;//ìáê¾Ïμí3ÕyÔúÔËDD
i=0;
}
}
}
一周热门 更多>