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 Reply Children
  • 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

  • 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

Related