智能车制作
标题:
STM32 DMA_GetCurrDataCounter()函数值不变!
[打印本页]
作者:
辰晨
时间:
2012-7-22 15:12
标题:
STM32 DMA_GetCurrDataCounter()函数值不变!
最近尝试用USART2的DMA模式来发送接收数据。接收的时候,发现DMA_GetCurrDataCounter()的值维持DMA_BufferSize的大小不变。若用while(DMA_GetFlagStatus(DMA1_FLAG_TC6)==RESET);则一直循环着。
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOD|RCC_APB2Periph_USART1,ENABLE);
//启动DMA时钟
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);
void USART2_Configuration(void)
{
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
USART_Init(USART2, &USART_InitStructure);
USART_Cmd(USART2, ENABLE);
USART_DMACmd(USART2,USART_DMAReq_Tx,ENABLE);
USART_DMACmd(USART2,USART_DMAReq_Rx,ENABLE);
}
//接收部分
DMA_DeInit(DMA1_Channel6);
DMA_InitStructure.DMA_PeripheralBaseAddr = USART2_DR_Base;
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)SensorsData;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize = Counts;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;//正常或者循环。
DMA_InitStructure.DMA_Priority = DMA_Priority_Medium;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel6, &DMA_InitStructure);
DMA_Cmd(DMA1_Channel6,ENABLE);
//发送正常
作者:
ccw163165
时间:
2012-7-27 19:35
楼主DMA_GetCurrDataCounter()这个在哪里???
欢迎光临 智能车制作 (http://111.231.132.190/)
Powered by Discuz! X3.2