Using UARTE - eDMA

Hi guys,

I am currently trying to make my uart work with eDMA functionality.

Up to this point I am able to read using polling, and as second method using IRQ with a message queue.

Unfortunately I could not find any concrete examples regarding eDMA.

I tried something psoted 3 years ago but it doesn't seem to work.

I am not crashing anything but the callback doesn't seem to trigger.

My hardware is also not using an HWFC

Maybe I am doing something wrong.

 UARTE driver configuration for nRF52840 

if you guys have any other ideas or suggestions please let me know.

Parents
  • Hi

    Is it correct that you are developing for nRF5340? To my knowledge, eDMA is not available for the nRF5340 and the nRF9160 (see this related case). In case you are developing for a 52 nRF52 series chip, eDMA is available, and that ticket should lead you towards your destination.

    Let me know if this answers your question!

    Kind regards,
    Andreas

  • Hi Andreas,

    So the nRF5340 doesn't offer any kind of DMA?

    The thing is that under the documentation eDMA is listed under the following:

    So now I am a bit confused whether it really does or not. If it does not then the data we get will be parsed by the CPU.
    Otherwise eDMA would be really handy
  • Hi,

    It looks like you are correct. I jumped some hoops when referring to the case in my previous answer, which says "UART without easyDMA is not available on the nRF9160 or nRF5340", and not the other way around. I will have to do some more digging into your case and I will come back before the weekend with a more definite answer!

    Kind regards,
    Andreas

  • Hi Andreas,

    Thanks for the help!

    Let me know when/if you find something.

  • Hi,

    Apologies for the delay in answer time. We are currently in the main summer vacation period here in Norway so we are running with a reduced support staff which might cause some increase in answer time

    On newer devices such as the nRF5340 or nRF9160 UARTE (UART with eDMA) is the default UART peripheral, and non-eDMA does not exist. Every sample in NCS that uses the uart, such as the central_uart and peripheral_uart contains board files that sets up the sample such that the UARTE peripheral is used. Thus for the nRF5340DK, which you are using, every sample is using UARTE. If you want to use it without eDMA (Only for 52-devices or older), you can follow what Heidi explains in the ticket I linked in a previous reply.

    I recommend that you examine those two samples, and if you have 2 boards/a board and a phone you can test them.

    I tried something psoted 3 years ago but it doesn't seem to work.

    The thing you tried which were posted 3 years ago might be out of date. Can you link or explain what you tried? It could be that the API/documentation you were following does not apply at all

    I am not crashing anything but the callback doesn't seem to trigger.

    Can you attach the code you have written for this? 

    Kind regards,
    Andreas

Reply
  • Hi,

    Apologies for the delay in answer time. We are currently in the main summer vacation period here in Norway so we are running with a reduced support staff which might cause some increase in answer time

    On newer devices such as the nRF5340 or nRF9160 UARTE (UART with eDMA) is the default UART peripheral, and non-eDMA does not exist. Every sample in NCS that uses the uart, such as the central_uart and peripheral_uart contains board files that sets up the sample such that the UARTE peripheral is used. Thus for the nRF5340DK, which you are using, every sample is using UARTE. If you want to use it without eDMA (Only for 52-devices or older), you can follow what Heidi explains in the ticket I linked in a previous reply.

    I recommend that you examine those two samples, and if you have 2 boards/a board and a phone you can test them.

    I tried something psoted 3 years ago but it doesn't seem to work.

    The thing you tried which were posted 3 years ago might be out of date. Can you link or explain what you tried? It could be that the API/documentation you were following does not apply at all

    I am not crashing anything but the callback doesn't seem to trigger.

    Can you attach the code you have written for this? 

    Kind regards,
    Andreas

Children
  • Hi Andreas,

    Thanks for getting back to me.
    So what we are trying to do is get the data from the UART with DMA without involving the cpu at all. Our next step would be to feed that data to I2C using also DMA.

    void zedF9_write_queue_cb(const struct device *dev, void *user_data)
    {
    	uint8_t cnt = 0;
    	// current char
    	uint8_t cc;
    	struct DataPack *dp = user_data;
    
    	if(!uart_irq_update(dev)) {
    		return;
    	}
    
    	while (uart_irq_rx_ready(dev)) {
    		uart_fifo_read(dev, &cc, 1);
    
    		uint16_t cnt = dp->buffer_pos;
    		char cp = 0;
    
    		//if(cnt > 0)
    		//	cp = dp->buffer[dp->buffer_pos - 1];
    
    		if ((cc  == '\n')) {
    			/* terminate string */
    			dp->buffer[dp->buffer_pos    ] = cc;
    			dp->buffer[dp->buffer_pos + 1] =  0;
    			k_msgq_put(&(dp->z9_queue), dp->buffer, K_NO_WAIT);
    			dp->buffer_pos = 0;
    		} 
    		else if(dp->buffer_pos < (sizeof(dp->buffer) - 1)) {
    			dp->buffer[dp->buffer_pos++] = cc;
    		}
    	}
    }

     This is the code we are using currently. Fairly simple we just put the characters to a message queue and consume them in another function (main). This method works fine no issues whatsoever. We just wanted to see if it's possible to do the same with DMA passing from memory to memory -- UART to I2C

  • Hey Andreas,

    I started checking the 2 examples you pointed me to, central and peripheral_uart. The are quite different. The peripheral_art uses the async implementation and quite more complex than the central example.

    You pointed out that both are using DMA right? What would be a better starting point? Is the async architecture required for DMA or it could be done the same way as the central example?

  • Hi

    DorianN said:
    So what we are trying to do is get the data from the UART with DMA without involving the cpu at all. Our next step would be to feed that data to I2C using also DMA.

    Yes, this is possible to do, but I am a bit uncertain about what you mean "without involving the cpu at all". Could you explain this? Because the processor will at least be involved in setting up and controlling in and output to the peripherals

    DorianN said:
    You pointed out that both are using DMA right?

    Yes, Nordic UART Service (NUS), which the samples are based on, uses UART with eDMA by default.

    DorianN said:
    Is the async architecture required for DMA

    It is not a requirement for DMA, but it is for UART (Universal asynchronous receiver-transmitter)

    Kind regards,
    Andreas

Related