Electrical – stm32 gpio to dma

dmanucleostm32stm32f4stm32f7

I have a few questions regarding using the DMA of the stm32f7 board (nucleo F722ZE ).

1) So to get started I'll explain what I'm doing:

I need to read data from 2 GPIO pins (ADC) and will have a clock signal fed to the stm32f7 from the device supplying the data. I plan on letting the clock signal trigger an interrupt timer and whenever the timer is triggered I want the DMA to do a memory to peripheral transfer. The memory will be 2 bits on the GPIO port with the peripheral being a SPI line coupled to a SD card.

2) Accessing the data:

I referred to the arm cortex 7 manual and found the following:

The GPIOC port is mapped to 0x40020800 – 0x40020BFF and the input data registers are set at an offset of 0x14.

So I take the memory mapped base register (0x40020800 and add 0x14 to it) Therefore the source address I supply to the DMA will be 0x40020814?

3) Having the DMA shift out this data.

This might be the larger problem. Once I have the data at the GPIO pins, I'll essentially be receiving it bit for bit and the data is actually 24 bits long, per pin. So in total each gpio pin will receive 24 bit packs of data. Although when the external signal triggers the timer, I'll only have one bit at each of the GPIO's.

Is there any way that the DMA can selectively pull out the data bit by bit, till it has all 24 bits and then send it over the SPI. Using some sort of buffer and burst transfer? Otherwise it seems the DMA can do a minimum of a byte transfer, which will require me to send massive amounts of garbage bits for every bit I transfer.

Finally:
To summarize, I'm uncertain about the location of the GPIO data, is the address I put down correct and I'm completely unsure of how to go about having the DMA transfer this data??

Any help will be appreciated!

Best Answer

  1. GPIO is not the ADC. I do not understand what you mean. If is an external ADC it probably transfers it using standard interfaces like I2C or SPI. If you want to read the analog data you need to use then the internal ADC
  2. You have everything defined in the CMSIS headers. You do not need to think about the physical addresses. you will access the GPIO registers whis way : GPIOA -> MODER for example. There are all bits definitions as well in the human readable form.
  3. DMA does not transfer bits only bytes, halfwords or words. But you need to consider more smart way of reading them than toye inital idea. As you did not write what is the device connected I cant help you more.
  4. My advise - start from something easier - learn how to use CMSIS and the peripherals in your micro. I am 100% sure that you can use one of the standard ones: I2C, SPI or U(S)ART for it without any bitreading from the GPIO