how to configure 16-bit GPIOE port for DMA access

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

jscott
Posts: 129
Joined: Tue Jul 03, 2012 3:50 pm
Location: Middle Georgia, USA
Contact:

how to configure 16-bit GPIOE port for DMA access

Postby jscott » Thu Jan 30, 2014 6:58 am

I am getting ready to set up DMA access to the 16-bit I/O port GPIOE.

I am going to set the i/o port as output using the config file, but
I am not sure how to specify the data register to the DMA function.

It looks like this may work, but I am not sure....

Code: Select all

  // Set the destination address
  dmaStreamSetMemory0( STM32_DMA1_STREAM5, GPIO_PORTE->ODR );


Thanks
John Scott

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: how to configure 16-bit GPIOE port for DMA access

Postby Giovanni » Thu Jan 30, 2014 9:31 am

You should use this one for the peripheral side:

Code: Select all

/**
 * @brief   Associates a peripheral data register to a DMA stream.
 * @note    This function can be invoked in both ISR or thread context.
 * @pre     The stream must have been allocated using @p dmaStreamAllocate().
 * @post    After use the stream can be released using @p dmaStreamRelease().
 *
 * @param[in] dmastp    pointer to a stm32_dma_stream_t structure
 * @param[in] addr      value to be written in the PAR register
 *
 * @special
 */
#define dmaStreamSetPeripheral(dmastp, addr) {                              \
  (dmastp)->stream->PAR  = (uint32_t)(addr);                                \
}


and this one as memory source:

Code: Select all

/**
 * @brief   Associates a memory destination to a DMA stream.
 * @note    This function can be invoked in both ISR or thread context.
 * @pre     The stream must have been allocated using @p dmaStreamAllocate().
 * @post    After use the stream can be released using @p dmaStreamRelease().
 *
 * @param[in] dmastp    pointer to a stm32_dma_stream_t structure
 * @param[in] addr      value to be written in the M0AR register
 *
 * @special
 */
#define dmaStreamSetMemory0(dmastp, addr) {                                 \
  (dmastp)->stream->M0AR  = (uint32_t)(addr);                               \
}


Be prepared to a careful read of the STM32F4 Reference Manual because that DMA is very complex.

Giovanni

jscott
Posts: 129
Joined: Tue Jul 03, 2012 3:50 pm
Location: Middle Georgia, USA
Contact:

Re: how to configure 16-bit GPIOE port for DMA access

Postby jscott » Thu Jan 30, 2014 2:58 pm

Hi Giovanni,

DMA is FUN!!! :D :D
I have been using DMA for stuff since the Z80 days in the 80's. It takes a while
to wrap your mind around the concepts, but it is not too hard from there...

I have been working through the STM32 docs for the last week and a half.
I think I have figured out the STM32 DMA( famous last words :o :o ), but i am stumbling
over figuring out how to do things with Chibios. Its tricky when the documentation for
dmaStreamSetMemory0() says Associates a memory destination to a DMA stream
when in this case I am specifying a DMA source address.

I see in the examples I messed this up... AGAIN!!! :oops: :oops:

What I am not sure of here, is how to specify the port parameter. There are many
#defines and levels of indirection, and I am having a hard time sorting out how to
pass the address of the output port data register to the dmaStreamSetPeripheral.

I have tried PORTE->ODB, GPIOE_BASE->ODB and GPIO_PORTE->ODB

Thanks for all your help
-John

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: how to configure 16-bit GPIOE port for DMA access

Postby Giovanni » Thu Jan 30, 2014 3:06 pm

The memory side can be both source or destination depending on the transfer direction.

BTW, I am not saying that DMA is difficult, it is specifically the F4 DMA that is complex, see the RM for details. The GPIO register to use is documented there to, you can use the ST header macros to get the address.

Giovanni

rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am
Location: Austria

Re: how to configure 16-bit GPIOE port for DMA access

Postby rubenswerk » Thu Sep 25, 2014 9:51 pm

Hello,

I try to output a parallel 16 bit datastream via port E pins.
Output transfer rate is ~1MHz.
I configured TIM2 to trigger DMA transfers from memory to GPIOE->ODR peripheral.
Unfortunately, this does not work at all.
With other peripheral registers DMA works as expected, but with GPIO as destination, nothing happens.
Is there a restriction that GPIO cannot be accessed via DMA?
In the ST Forum I read that it might not work because GPIO is not connected to APB bus and memory-to-memory mode (with GPIO or FSMC as destination) should be used instead.
But in that case, I cannot use a timer to trigger the transfers at the desired transfer rate.

Anybody who used DMA based GPIO?
Any other ideas how to create a parallel bitstream?

Greetings, RuWe!

jscott
Posts: 129
Joined: Tue Jul 03, 2012 3:50 pm
Location: Middle Georgia, USA
Contact:

Re: how to configure 16-bit GPIOE port for DMA access

Postby jscott » Fri Sep 26, 2014 12:33 am

If I remember correctly only dma2 can connect to the gpio ports. This
bit into me and chewed for about 2 weeks before I figured it out.

I don't remember what timer I had to use to trigger the dma, but the dma
will really dictate which ones you can use.

Are you doing a blinky light project? The specs sound about right....

-John

rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am
Location: Austria

Re: how to configure 16-bit GPIOE port for DMA access

Postby rubenswerk » Fri Sep 26, 2014 8:16 am

Thanks John, I found it last night somewhere in the ST forum.
You're right, DMA2 is able to access GPIO, but DMA1 is not!
In my case, I use TIM8 as trigger time base - seems to work now.

Yes, I'm feeding several WS2811 datastreams in parallel to have high update rate for LEDs.


Return to “STM32 Support”

Who is online

Users browsing this forum: Bing [Bot] and 21 guests