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.

  • 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