Author Topic: Using HAL_SPI_Transmit_DMA() from STM32duino?  (Read 1090 times)

0 Members and 2 Guests are viewing this topic.

Offline Rudolph RiedelTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: de
Using HAL_SPI_Transmit_DMA() from STM32duino?
« on: January 04, 2021, 03:38:13 pm »
Hello,

after playing with my code for a couple of days now, on and off,  |O, I used PlatformIO to build a "stm32cube" project for the Nucleo-64 board with STM32F446RE I have.
I added the necessary extra code like SystemClock_Config() that STM32CubeMX generated and the SPI and DMA functions that I implemented for the STM32duino and that are using HAL and LL functions.

And damn, it works, sending data over LL_SPI_TransmitData8(), HAL_SPI_Transmit() and HAL_SPI_Transmit_DMA()
just works.

To finally come to a question, what is failing with STM32duino is the DMA interrupt.
HAL_SPI_Transmit_DMA() needs the associated IRQHandler to call HAL_DMA_IRQHandler().

So I am using this now:
void DMA2_Stream3_IRQHandler(void)
{
   HAL_DMA_IRQHandler(&eve_dma_handle);
}

And this works just fine in the stm32cube" project.

But on the STM32duino side this IRQ handler never gets called.
What extra steps do I need to make this interrupt handler work on the STM32duino side?
 

Offline ozcar

  • Frequent Contributor
  • **
  • Posts: 322
  • Country: au
Re: Using HAL_SPI_Transmit_DMA() from STM32duino?
« Reply #1 on: January 04, 2021, 05:46:40 pm »
Perhaps you have to add extern "C" to your interrupt routine definition.

If that does not work, you may be better off asking on www.stm32duino.com .
 
The following users thanked this post: Rudolph Riedel

Offline Rudolph RiedelTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: de
Re: Using HAL_SPI_Transmit_DMA() from STM32duino?
« Reply #2 on: January 04, 2021, 06:10:43 pm »
That was exactly what was missing, thanks!  :) :)  :-+

extern "C" void DMA2_Stream3_IRQHandler(void)
{
   HAL_DMA_IRQHandler(&eve_dma_handle);
}

This is only required for this one, the callback function HAL_SPI_TxCpltCallback() is fine without it.


And I am not even using C++, the file is named .cpp since the Arduino classes require it.
Or well, maybe there is annother way to use for example the SPI class from a .c file but it has been a while since I looked
for a solution to this.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf