2013-04-02 09:40 AM
Hi everbody, I have some problems to configure the DMA for the USART3.
I configure the USART3/DMA and nothing is written in the register. I have read the exemple project and answers on this forum, I don't find the problem./* COM2 - NETWORK IN */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD,ENABLE);
RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_DMA1, ENABLE);
GPIO_PinAFConfig(EVAL_COM2_TX_GPIO_PORT,EVAL_COM2_TX_SOURCE,EVAL_COM2_TX_AF);
GPIO_PinAFConfig(EVAL_COM2_RX_GPIO_PORT,EVAL_COM2_RX_SOURCE,EVAL_COM2_RX_AF);
/* Configure USART Tx and Rx as alternate function push-pull */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Pin = EVAL_COM2_TX_PIN;
GPIO_Init(EVAL_COM2_TX_GPIO_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = EVAL_COM2_RX_PIN;
GPIO_Init(EVAL_COM2_RX_GPIO_PORT, &GPIO_InitStructure);
/* Configuration : 115200 bauds, 8 N 1 OK */
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init(EVAL_COM2,&USART_InitStructure);
/* Configure DMA controller to manage USART TX and RX DMA request ----------*/
DMA_DeInit(DMA1_Stream1);
DMA_Cmd(USARTx_RX_DMA_STREAM, DISABLE);
DMA_InitStructure.DMA_PeripheralBaseAddr = USARTx_DR_ADDRESS;
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_VeryHigh;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_InitStructure.DMA_Channel = DMA_Channel_4;//USARTx_RX_DMA_CHANNEL;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)RxBuffer;
DMA_InitStructure.DMA_BufferSize = (uint8_t)2;
DMA_Init(DMA1_Stream1/*USARTx_RX_DMA_STREAM*/, &DMA_InitStructure);
/* Enable the DMA RX Stream */
DMA_Cmd(DMA1_Stream1/*USARTx_RX_DMA_STREAM*/, ENABLE);
/* Enable the USART Rx DMA request */
USART_DMACmd(EVAL_COM2, USART_DMAReq_Rx, ENABLE);
/* Enable the USARTx Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Stream1_IRQn;//EVAL_COM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;//0x0F;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;//0x0F;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/*USART_ITConfig(EVAL_COM2, USART_IT_TC, DISABLE);
USART_ITConfig(EVAL_COM2, USART_IT_RXNE, ENABLE); */
DMA_ITConfig(DMA1_Stream1/*(USARTx_RX_DMA_STREAM)*/, DMA_FLAG_TCIF1, ENABLE);
/* Enable USART */
USART_Cmd(EVAL_COM2, ENABLE);
/* Configuration de la PIN REDE */
COMRDInit(COM2);
Could you tell me if I have done something wrong.
Thank you in advance,
2013-04-02 10:07 AM
Lot of #defines I can't see that could potentially break it, other than that doesn't look unreasonable.