小学生
最后登录1970-1-1
在线时间 小时
注册时间2017-6-6
|
楼主 |
发表于 2017-6-6 16:19:19
|
显示全部楼层
我擦,我后半段呢
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;//存储器增量模式
// DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;//外设数据长度:8位
// DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;//存储器数据长度:8位
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;//外设数据长度: 16位
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;//存储器数据长度: 16位
// DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;//外设数据长度: 32位
// DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;//存储器数据长度: 32位
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;// 使用循环模式 别改 11111111111111111111111111111111111111111
// DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;// 使用普通模式
DMA_InitStructure.DMA_Priority = DMA_Priority_High;//高等优先级
// DMA_InitStructure.DMA_Priority = DMA_Priority_Medium;//中等优先级
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;//存储器突发单次传输
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;//外设突发单次传输
DMA_Init(DMA_Streamx, &DMA_InitStructure);//初始化DMA Stream
DMA_Cmd(DMA2_Stream0,ENABLE);
主函数
#define SEND_BUF_SIZE 8 //发送数据长度,最好等于sizeof(TEXT_TO_SEND)+2的整数倍.
u16 SendBuff[SEND_BUF_SIZE]; //发送数据缓冲区
int main(void)
{
// u16 tt=0;
u16 j=0;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组2
delay_init(168); //初始化延时函数
uart_init(115200); //初始化串口波特率为115200
// LED_Init(); //初始化LED
// LCD_Init(); //初始化LCD接口
// KEY_Init();
Adc_Init(); //初始化ADC
MYDMA_Config(DMA2_Stream0,DMA_Channel_0,(u32)&ADC1->DR,(u32)SendBuff,1);//DMA2,STEAM7,CH4,外设为串口1,存储器为SendBuff,长度为:SEND_BUF_SIZE.111111111111111111111111111
while(1)
{
ADC_SoftwareStartConv(ADC1);//使能ADC的软件转换启动功能
ADC_DMARequestAfterLastTransferCmd(ADC1,ENABLE); //源数据变化时开启DMA传输,不能改
// ADC_DMACmd(ADC1, ENABLE);
// MYDMA_Enable(DMA2_Stream0,1); //开始一次DMA传输! 111111111111111111111111111
if(DMA_GetFlagStatus(DMA2_Stream0,DMA_FLAG_TCIF0)!=RESET)//等待DMA2_Steam7传输完成
{
DMA_ClearFlag(DMA2_Stream0,DMA_FLAG_TCIF0);//清除DMA2_Steam7传输完成标志
printf("Value%d\r\n",ADC_GetConversionValue(ADC1));
printf("j%d\r\n",j);
printf("SendBuff%d\r\n",SendBuff[j]);
printf("Send0Buff%d\r\n",SendBuff[0]);//11111111111111111111111111111111111111111111111111111111
j++;
if(j==SEND_BUF_SIZE)
{
j=0;
}
}
}
}
串口助手j0
SendBuff3850
Send0Buff3850
Value3850
j1
SendBuff0
Send0Buff3839
Value3839
j2
SendBuff0
Send0Buff3851
Value3851
j3
SendBuff0
Send0Buff3864
Value3864
j4
SendBuff0
Send0Buff3863
Value3863
j5
SendBuff0
Send0Buff3848
Value3848
j6
SendBuff0
Send0Buff3854
Value3854
j7
SendBuff0
Send0Buff3848
Value3848
j0
SendBuff3854
Send0Buff3854
Value3854
j1
SendBuff0
Send0Buff3852
Value3852
j2
SendBuff0
Send0Buff3835
Value3835
j3
SendBuff0
Send0Buff3839
Value3839
|
|