2007-03-05 07:12 AM
2011-05-17 12:39 AM
Hi, I am currently trying to set DMA to receive with UART FIFO. At the moment, i am able to receive bytes and store it in my buffer (with DMA) :p .
I would like to reset my buffer pointer after each reception and notify the main App to check the buffer for new data. Where can I do this ? In the DMA interrupt, UART interrupt. I try to set a DMA interrupt without success. Help would be appreciatedCode:
DMA_StructInit(&DMA_InitStruct); DMA_InitStruct.DMA_Channel_LLstItm = 0; DMA_InitStruct.DMA_Channel_SrcAdd =(u32)(&UART0->DR); DMA_InitStruct.DMA_Channel_DesAdd =(u32)(&RxBuffer[0]); DMA_InitStruct.DMA_Channel_DesWidth=64; DMA_InitStruct.DMA_Channel_SrcWidth=16; DMA_InitStruct.DMA_Channel_SrcBstSize = DMA_DesBst_8Data ; DMA_InitStruct.DMA_Channel_FlowCntrl = DMA_FlowCntrl_Perip2; DMA_InitStruct.DMA_Channel_Src = DMA_SRC_UART0_RX; DMA_ChannelSRCIncConfig (DMA_UART0_RX_CHANNEL, DISABLE); DMA_ChannelDESIncConfig (DMA_UART0_RX_CHANNEL, ENABLE); /* clear all pending interrupt before init */ DMA_ClearIT(Channel6,DMA_TCC); DMA_ClearIT(Channel6,DMA_EC); DMA_Init(DMA_UART0_RX_CHANNEL,&DMA_InitStruct); DMA_ITConfig(DMA_UART0_RX_CHANNEL, ENABLE); /*Enable the TCI interrupt for channel0*/ DMA_ITMaskConfig(DMA_UART0_RX_CHANNEL, DMA_ITMask_ITC, ENABLE); DMA_ITMaskConfig(DMA_UART0_RX_CHANNEL, DMA_ITMask_IE, DISABLE); /* Update the DMA channel0 registers with the structure*/ DMA_ChannelCmd (DMA_UART0_RX_CHANNEL, ENABLE); Here is my VIC config in my main App.Code:
DMA_ClearIT(Channel0,DMA_TCC); // CLEAR OC flag for next interrupt VIC_Config(DMA_ITLine, VIC_IRQ, 3); VIC_ITCmd(DMA_ITLine, ENABLE); UART_ClearITPendingBit(UART0,UART_IT_ReceiveTimeOut); UART_ClearITPendingBit(UART0,UART_IT_Receive); VIC_Config(UART0_ITLine, VIC_IRQ, 3); VIC_ITCmd(UART0_ITLine, ENABLE); Here is my UART config void UART_Configuration(void) { UART_InitTypeDef UART_InitStructure; UART_InitStructure.UART_WordLength = UART_WordLength_7D; UART_InitStructure.UART_StopBits = UART_StopBits_2; UART_InitStructure.UART_Parity = UART_Parity_No ; UART_InitStructure.UART_BaudRate = 115200; UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None; UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx; UART_InitStructure.UART_FIFO = UART_FIFO_Enable; UART_InitStructure.UART_TxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */ UART_InitStructure.UART_RxFIFOLevel = UART_FIFOLevel_1_8; /* FIFO size 16 bytes, FIFO level 8 bytes */ UART_DeInit(UART0); UART_Init(UART0, &UART_InitStructure); /* -------Enable the DMA request for the Tx FIFO */ UART_DMACmd(UART0, UART_DMAReq_Tx , ENABLE); /* -------Enable the DMA request for the Tx FIFO */ UART_DMACmd(UART0, UART_DMAReq_Rx , ENABLE); /* Enable interrupt for UART0 */ UART_ITConfig(UART0,UART_IT_Receive,ENABLE); UART_ITConfig(UART0,UART_IT_ReceiveTimeOut,ENABLE); /* Enable the UART0 */ UART_Cmd(UART0, ENABLE); }