Author Topic: stm32 HAL SPI with DMA  (Read 4434 times)

0 Members and 1 Guest are viewing this topic.

Offline sortovarituTopic starter

  • Newbie
  • Posts: 2
  • Country: by
stm32 HAL SPI with DMA
« on: August 21, 2018, 08:13:45 pm »
Is it possible to use HAL_SPI_Transmit together with HAL_SPI_Transmit_DMA??
For example:
HAL_SPI_Transmit(SPI2, arr_1, 0x04, 1);
HAL_SPI_Transmit_DMA(SPI2, arr_2 , 0x04);

My issue that the second command(HAL_SPI_Transmit_DMA(SPI2, arr_2 , 0x04);) does not send any data to SPI
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14472
  • Country: fr
Re: stm32 HAL SPI with DMA
« Reply #1 on: August 22, 2018, 06:15:13 pm »
You may want to check the error codes returned by those two functions, that may help.
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: stm32 HAL SPI with DMA
« Reply #2 on: August 22, 2018, 06:54:04 pm »
It's definitely possible.

Of course, the transmission from one call must be completed before the other one (or the same!) can be invoked.
If not, the HAL will return an error (HAL_BUSY).

The DMA setup might be wrong, can you show us your code?

Nandemo wa shiranai wa yo, shitteru koto dake.
 
The following users thanked this post: sortovaritu

Online Berni

  • Super Contributor
  • ***
  • Posts: 4954
  • Country: si
Re: stm32 HAL SPI with DMA
« Reply #3 on: August 22, 2018, 07:00:01 pm »
You often need to set up the DMA separately for things to work, could need certain interrupts set up and there might be other limitations with what memory areas the DMA can access. If any of it goes wrong you might get a hard fault, nothing happening or the driver becoming confused.

You most definitely have to watch out when using both that the DMA is done with its work before you try to do anything else. There are functions you can call to find out or check the contents of the SPI driver struct.

And sometimes the HAL just doesn't do exactly what you want, in that case you can sometimes copy paste an existing HAL function and modify it so that it works in the way you want.
 
The following users thanked this post: sortovaritu

Offline sortovarituTopic starter

  • Newbie
  • Posts: 2
  • Country: by
Re: stm32 HAL SPI with DMA
« Reply #4 on: August 23, 2018, 07:26:00 am »
I found a Solution:
DMA should be initiated before SPI initiation.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf