uart dma lpc54

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

uart dma lpc54

1,233 Views
nluca
Contributor III

I'm trying to set up the DMA to automatically transfer the data received by UART1 on a memory buffer. The processor is the LPC54102. Here is the code I'm using to set up the UART and the DMA.

Does anyone have any idea on what's wrong or missing here?

Thanks!

Chip_UART_Disable(LPC_USART1);

Chip_IOCON_PinMux(LPC_IOCON, 0, 5, IOCON_MODE_INACT | IOCON_DIGITAL_EN, IOCON_FUNC1);

Chip_IOCON_PinMux(LPC_IOCON, 0, 6, IOCON_MODE_INACT | IOCON_DIGITAL_EN, IOCON_FUNC1);

Chip_UART_special_SetBaud(GPS_USART, 115200);

usart_config = ( UART_CFG_DATALEN_8 | UART_CFG_PARITY_NONE | UART_CFG_STOPLEN_1 );
Chip_UART_ConfigData(LPC_USART1, usart_config);
Chip_UART_TXEnable(LPC_USART1);


Chip_DMA_DeInit(LPC_DMA);
Chip_DMA_Init(LPC_DMA);
Chip_DMA_Disable(LPC_DMA);
Chip_DMA_Enable(LPC_DMA);

Chip_DMA_DisableChannel(LPC_DMA, DMAREQ_UART1_RX);
Chip_DMA_ClearErrorIntChannel(LPC_DMA, DMAREQ_UART1_RX);30

tDmaUartRxDesc.source = DMA_ADDR(&LPC_USART1->RXDAT);
tDmaUartRxDesc.dest = DMA_ADDR(pabDataBuffer );
tDmaUartRxDesc.next = DMA_ADDR(0);
tDmaUartRxDesc.xfercfg = DMA_XFERCFG_CFGVALID |
                                            DMA_XFERCFG_SETINTA |
                                            DMA_XFERCFG_WIDTH_8 |
                                            DMA_XFERCFG_SRCINC_0 |
                                            DMA_XFERCFG_DSTINC_1 |
                                            DMA_XFERCFG_XFERCOUNT(230); 

while (!Chip_DMA_SetupTranChannel(LPC_DMA, DMAREQ_UART1_RX, &tDmaUartRxDesc)) {}
Chip_DMA_SetupChannelTransfer(LPC_DMA, DMAREQ_UART1_RX, tDmaUartRxDesc.xfercfg);

Chip_DMA_SetupChannelConfig(LPC_DMA, DMAREQ_UART1_RX, (DMA_CFG_PERIPHREQEN | DMA_CFG_TRIGBURST_SNGL | DMA_CFG_CHPRIORITY(0)));
Chip_DMA_EnableIntChannel(LPC_DMA, DMAREQ_UART1_RX);

NVIC_EnableIRQ(DMA_IRQn);

Chip_DMA_EnableChannel(LPC_DMA, DMAREQ_UART1_RX);

Chip_UART_Enable(LPC_USART1);

Labels (2)
0 Kudos
5 Replies

1,065 Views
nluca
Contributor III

Hi Alice,

Thanks for pointing that out for me. I had already come across it and in fact I've been comparing that code with mine. I'm doing the same settings, apart not using the FIFO and using the "Chip_" API.

Still I don't see what's missing in my code that prevents the DMA to work. If I SW trigger the transfer while debugging the code on the IDE, the transfer takes place and the data end up in my buffer. However, if I leave the UART peripheral to send a request to the DMA, the transfer never gets kicked off. Would appreciate any help on this!

Thanks,

Luca

0 Kudos

1,065 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Luca,

I recommend you first test the demo, then change it to your own code based on it .

Check at place you change that can't work.

If still can't work, you can send your whole project to me,  I help you check it on my side.

BR

Alice

0 Kudos

1,065 Views
nluca
Contributor III

I'm still having troubles on this task. Could you kindly have a look at my code and see what's missing, please?

I cannot share the whole project as there are protected code in there. I can assure the code I posted above works well if I kick off the transaction manually by enabling the SW trigger. However I want the DMA to be kicked off by the UART peripheral request instead, without the needing of a manual trigger.

Thanks.

0 Kudos

1,065 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Luca,

Sorry only through the part of code, I also haven't find the problem,

you can compare the DMA config registers between example  code with yours,

especially the Channel configuration registers:

pastedImage_1.png

You can also can delete your other codes, only includes the UART-DMA , I can help you check.


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,065 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Luca N,

There is UART DMA demo under SDK demo , you can refer to it :

pastedImage_1.png


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos