Learn MoreFAQsTutorials

8 posts / 0 new
Last post
techteh
Offline
Last seen: 5 months 6 days ago
Joined: 2018-07-16 12:09
GPIO DMA

Hi Dialog,
Does the internal DMA of DA1468x support input from GPIO? if yes, how to initialize the trigger of DMA? what can I do if I want to trig DMA with timer0 clock and the source of GPIO->P4_DATA_REG?
thank you in advance.

Keywords: 
Device: 
PM_Dialog
Offline
Last seen: 2 days 5 hours ago
Staff
Joined: 2018-02-08 11:03
Hi techteh,

Hi techteh,

The DMA is used when transferring a big amount of data quickly without using the CPU, for example when transferring data through I2C or SPI and not when want to read a GPIO register. The register that you are using is 1 byte, so the transaction will take long, because the initialization of DMA is too slow. Also, be aware that the initialization of the DMA will take too long from the transactions of your data. So, I highly suggest you to read the GPIO register directly without using the DMA, because this technique is faster from using the DMA.

Thanks, PM_Dialog

techteh
Offline
Last seen: 5 months 6 days ago
Joined: 2018-07-16 12:09
Hi,

Hi,
Thanks for your reply,
Yes I want to transfer a big amount of data quickly without using the CPU. This big data passes through GPIO. I have a 2K bytes Array in memory and I want to read GPIO Port 4 value and save those bytes to this 2K Bytes Array, every 1 micro second. This means that the dest_address is Array in memory and src_address is GPIO->P4_DATA_REG. So, My question is what about dma_req_mux? I have built a 1 MHz Clock signal for this. Is there any way to transfer GPIO value to an Array in memory with DMA and this Clock signal trigger?

Thanks.

MT_dialog
Offline
Last seen: 1 month 2 weeks ago
Staff
Joined: 2015-06-08 11:34
Hi techteh,

Hi techteh,

What you propose is possible you can have the DMA to perform memory to memory transations, so yes you can use the hw to transfer from the memory to the register of the desired
GPIO. But there is no implementation from Dialog on such a use case and also this kind of functionallity is not supported from the SDK, so you will have to use directly the low level drivers. Something like the code should do the work:

        gpio_bitbang.channel_number = HW_DMA_CHANNEL_1;
        gpio_bitbang.bus_width = HW_DMA_BW_HALFWORD;
        gpio_bitbang.irq_enable = HW_DMA_IRQ_STATE_ENABLED;
        gpio_bitbang.irq_nr_of_trans = sizeof(array);
        gpio_bitbang.dreq_mode = HW_DMA_DREQ_START;
        gpio_bitbang.a_inc = HW_DMA_AINC_TRUE;
        gpio_bitbang.b_inc = HW_DMA_BINC_FALSE;
        gpio_bitbang.circular = HW_DMA_MODE_NORMAL;
        gpio_bitbang.dma_prio = HW_DMA_PRIO_6;
        gpio_bitbang.dma_idle = HW_DMA_IDLE_INTERRUPTING_MODE;
        gpio_bitbang.dma_init = HW_DMA_INIT_AX_BX_AY_BY;
        gpio_bitbang.dma_req_mux = HW_DMA_TRIG_NONE;
        gpio_bitbang.src_address = (uint32_t)array;
        gpio_bitbang.dest_address = 0x50003002;
        gpio_bitbang.length = sizeof(array);
        gpio_bitbang.callback = fn;

        hw_dma_channel_initialization(&gpio_bitbang);
        hw_dma_channel_enable(gpio_bitbang.channel_number, HW_DMA_STATE_ENABLED);

Also the clock that the DMA uses is the system clock you cannot apply an external clock to the DMA in order to perform the transactions, if that is what you mean.

Thanks MT_dialog

techteh
Offline
Last seen: 5 months 6 days ago
Joined: 2018-07-16 12:09
Hi,

Hi,
I am so thankful for your reply and the sample code you provided.
I have not an external clock. I want to use internal timer 0 clock signal to trig DMA in every 1 microsecond. Is there anyway to do this? if not, you said that "HW_DMA_TRIG_NONE" means system clock that is 16 MHz in my case . Is there another way to reduce this clock value to 1 MHz for DMA trigger? 16 MHz is too high for my external device that is connected to the GPIO.

Thanks.

MT_dialog
Offline
Last seen: 1 month 2 weeks ago
Staff
Joined: 2015-06-08 11:34
Hi techteh,

Hi techteh,

The HW_DMA_TRIG_NONE means that as soon as you set the DMA_ON the DMA itself will start running with the DMA clock since in a memory to memory access cannot be triggered in a similar way that the peripherals can be triggered. Now as mentioned the DMA runs with the system clock, this doesn't mean that you will see your GPIOs toggling with 16MHz frequency, the DMA requires more than one cycle in order to do a transaction. Besides that by reducing the AHB clock or the APB clock in order to get the frequency that you would like you could get the frequency that you would like but its not such a good practice to have all the modules running in low clock for that. Additionally at some point the Core will also require the AHB bus and will stop the DMA from accessing the bus. What might be a solution is to generate false triggers at 1MHz from another peripheral (and keep the source and destination the same) in order for the device to perform a transaction in every trigger, but again you will have a dummy peripheral running in order to provide the time.

Thanks MT_dialog

techteh
Offline
Last seen: 5 months 6 days ago
Joined: 2018-07-16 12:09
Hello,

Hello,
I did your suggestion,
I used SPI peripheral for DMA trigger, and now my problem solved.

Thanks.

PM_Dialog
Offline
Last seen: 2 days 5 hours ago
Staff
Joined: 2018-02-08 11:03
Hi techteh,

Hi techteh,

Glad you figured your problem out.

Thanks, PM_Dialog