Hi, I am trying to integrate my code with embOS for ARM. I am trying to send and receive data through usart using DMA. When i run code with out integrating with embOS it is working fine for both Tx & Rx. After integrating with embOS Tx is working fine and DMA Rx is not receiving data but usart RHR is getting value.
USART is configured for normal mode, baud rate is 9600, parity - None, stop bits - 1.
Thanks & Regards.
Santhosh
DMA settings and recevie code is given below.
static void _ConfigureDma( void )
{
uint32_t dwCfg;
uint8_t iController;
/* Driver initialize */
DMAD_Initialize( &dmad, 0 );
/* IRQ configure */
IRQ_ConfigureIT(ID_DMAC0, 0, ISR_DMA);
IRQ_EnableIT(ID_DMAC0);
/* Allocate DMA channels for USART */
usartDmaTxChannel = DMAD_AllocateChannel( &dmad,
DMAD_TRANSFER_MEMORY, ID_USART);
usartDmaRxChannel = DMAD_AllocateChannel( &dmad,
ID_USART, DMAD_TRANSFER_MEMORY);
if ( usartDmaTxChannel == DMAD_ALLOC_FAILED
usartDmaRxChannel == DMAD_ALLOC_FAILED )
{
printf("DMA channel allocat error\n\r");
while(1);
}
/* Set RX callback */
DMAD_SetCallback(&dmad, usartDmaRxChannel,
(DmadTransferCallback)_DmaRxCallback, 0);
/* Configure DMA RX channel */
iController = (usartDmaRxChannel >> 8);
dwCfg = 0
| DMAC_CFG_SRC_PER(
DMAIF_Get_ChannelNumber( iController, ID_USART, DMAD_TRANSFER_RX ))
| DMAC_CFG_SRC_H2SEL
| DMAC_CFG_SOD
| DMAC_CFG_FIFOCFG_ALAP_CFG;
DMAD_PrepareChannel( &dmad, usartDmaRxChannel, dwCfg );
/* Configure DMA TX channel */
iController = (usartDmaTxChannel >> 8);
dwCfg = 0
| DMAC_CFG_DST_PER(
DMAIF_Get_ChannelNumber( iController, ID_USART, DMAD_TRANSFER_TX ))
| DMAC_CFG_DST_H2SEL
| DMAC_CFG_SOD
| DMAC_CFG_FIFOCFG_ALAP_CFG;
DMAD_PrepareChannel( &dmad, usartDmaTxChannel, dwCfg );
}
static void _DmaRx( void )
{
sDmaTransferDescriptor td;
td.dwSrcAddr = (uint32_t)&USART->US_RHR;
td.dwDstAddr = (uint32_t) pBuffer;
td.dwCtrlA = BUFFER_SIZE | DMAC_CTRLA_SRC_WIDTH_BYTE | DMAC_CTRLA_DST_WIDTH_BYTE;
td.dwCtrlB = DMAC_CTRLB_SRC_DSCR | DMAC_CTRLB_DST_DSCR
| DMAC_CTRLB_SIF_AHB_IF2 | DMAC_CTRLB_DIF_AHB_IF0
| DMAC_CTRLB_FC_PER2MEM_DMA_FC
| DMAC_CTRLB_SRC_INCR_FIXED
| DMAC_CTRLB_DST_INCR_INCREMENTING;
td.dwDscAddr = 0;
DMAD_PrepareSingleTransfer(&dmad, usartDmaRxChannel, &td);
DMAD_StartTransfer(&dmad, usartDmaRxChannel);
}
USART is configured for normal mode, baud rate is 9600, parity - None, stop bits - 1.
Thanks & Regards.
Santhosh
DMA settings and recevie code is given below.
static void _ConfigureDma( void )
{
uint32_t dwCfg;
uint8_t iController;
/* Driver initialize */
DMAD_Initialize( &dmad, 0 );
/* IRQ configure */
IRQ_ConfigureIT(ID_DMAC0, 0, ISR_DMA);
IRQ_EnableIT(ID_DMAC0);
/* Allocate DMA channels for USART */
usartDmaTxChannel = DMAD_AllocateChannel( &dmad,
DMAD_TRANSFER_MEMORY, ID_USART);
usartDmaRxChannel = DMAD_AllocateChannel( &dmad,
ID_USART, DMAD_TRANSFER_MEMORY);
if ( usartDmaTxChannel == DMAD_ALLOC_FAILED
usartDmaRxChannel == DMAD_ALLOC_FAILED )
{
printf("DMA channel allocat error\n\r");
while(1);
}
/* Set RX callback */
DMAD_SetCallback(&dmad, usartDmaRxChannel,
(DmadTransferCallback)_DmaRxCallback, 0);
/* Configure DMA RX channel */
iController = (usartDmaRxChannel >> 8);
dwCfg = 0
| DMAC_CFG_SRC_PER(
DMAIF_Get_ChannelNumber( iController, ID_USART, DMAD_TRANSFER_RX ))
| DMAC_CFG_SRC_H2SEL
| DMAC_CFG_SOD
| DMAC_CFG_FIFOCFG_ALAP_CFG;
DMAD_PrepareChannel( &dmad, usartDmaRxChannel, dwCfg );
/* Configure DMA TX channel */
iController = (usartDmaTxChannel >> 8);
dwCfg = 0
| DMAC_CFG_DST_PER(
DMAIF_Get_ChannelNumber( iController, ID_USART, DMAD_TRANSFER_TX ))
| DMAC_CFG_DST_H2SEL
| DMAC_CFG_SOD
| DMAC_CFG_FIFOCFG_ALAP_CFG;
DMAD_PrepareChannel( &dmad, usartDmaTxChannel, dwCfg );
}
static void _DmaRx( void )
{
sDmaTransferDescriptor td;
td.dwSrcAddr = (uint32_t)&USART->US_RHR;
td.dwDstAddr = (uint32_t) pBuffer;
td.dwCtrlA = BUFFER_SIZE | DMAC_CTRLA_SRC_WIDTH_BYTE | DMAC_CTRLA_DST_WIDTH_BYTE;
td.dwCtrlB = DMAC_CTRLB_SRC_DSCR | DMAC_CTRLB_DST_DSCR
| DMAC_CTRLB_SIF_AHB_IF2 | DMAC_CTRLB_DIF_AHB_IF0
| DMAC_CTRLB_FC_PER2MEM_DMA_FC
| DMAC_CTRLB_SRC_INCR_FIXED
| DMAC_CTRLB_DST_INCR_INCREMENTING;
td.dwDscAddr = 0;
DMAD_PrepareSingleTransfer(&dmad, usartDmaRxChannel, &td);
DMAD_StartTransfer(&dmad, usartDmaRxChannel);
}
The post was edited 1 time, last by SANTHOSH KUMAR ().