Skip to main content
timotet
Associate II
July 13, 2012
Question

stm32f0 spi dma and no interrupt

  • July 13, 2012
  • 13 replies
  • 2720 views
Posted on July 13, 2012 at 23:08

Hi

Ive been trying to get the SPI DMA TX interrupt to work with no luck.

Im trying to load an array onto the SPI bus then get the interrupt to finish the transaction.

attached is my spi, dma , and nvic setup code.

thanks in advance

tim

#stm32f0-spi-dma
This topic has been closed for replies.

13 replies

Tesla DeLorean
Guru
July 13, 2012
Posted on July 13, 2012 at 23:13

Please supply the include file.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
timotet
timotetAuthor
Associate II
July 13, 2012
Tesla DeLorean
Guru
July 14, 2012
Posted on July 14, 2012 at 11:58

It looks like quite a reasonable attempt, the logic makes sense. I don't like the while() loops in the DMA interrupt, but SPI doesn't seem to offer a NOT BSY (IDLE?) interrupt, and when the bus transaction is going to stop is obfuscated by the FIFO's. A whole load of implementation fail from ST there.

You have a #define that has a name and substitution which are identical, probably something I would try and avoid.

Is the problem that it never enters the interrupt, or that is gets stuck or unpredictable?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
timotet
timotetAuthor
Associate II
July 14, 2012
Posted on July 14, 2012 at 19:48

It never enters the interrupt. I single step it up to the DMAy_Channelx->CCR |= DMA_CCR_EN line in the DMA_Cmd function and then it goes in to a

WWDG interrupt.

Ive removed the duplicate #define and the while loops in my dma interrupt also.

thanks

Tesla DeLorean
Guru
July 14, 2012
Posted on July 14, 2012 at 20:08

then it goes in to a WWDG interrupt.

That probably means it's Hard faulting, GCC collects a whole bunch of the unassigned interrupts to an infinite loop. So perhaps you have an issue with the instruction set or linkage.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
timotet
timotetAuthor
Associate II
July 14, 2012
Posted on July 14, 2012 at 20:39

So perhaps you have an issue with the instruction set or linkage.

Any hints on where to look for theses issues.

Im using the standard peripheral libraries from ST.

The startup_stm32f0xx.s supplied by Atollic.

Im using the eclipse IDE.

Thanks again

Tim
Tesla DeLorean
Guru
July 14, 2012
Posted on July 14, 2012 at 23:07

As I recall the GNU/GCC assembler didn't like the  ''adds rX, rX, #4'' instructions in startup_stm32f0xx.s when I was porting the code.

You're saying you can get to the DMA_Cmd() before it faults, which would take you beyond that.

I think you need to get your project, or at least this SPI portion, condensed into a single source with main(), etc and present that in it's entirety.

I'd probably start by looking at the listing files, and the code paths for the SPI, or more specifically the DMA interrupt. At the Hard Fault I'd dig back in the stack frame and get a feel for the faulting PC (instruction address) and registers. That and the listing would pretty much point to a potential failure point. I'd check also the stack was within reasonable bounds.

If you're comfortable with zipping up a complete project file, with objects, listing and hex files, I could take a look.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
timotet
timotetAuthor
Associate II
July 14, 2012
Posted on July 15, 2012 at 00:07

Thanks for the info.

Yes I'm able to single step into the DMA_Cmd function.

After your last post I tried to run the program on another install of eclipse I have and

I get to the same point with the same error. This code compiles with no errors on both

eclipse installs. One is the latest Juno release and the other is the Indigo release. I'm using sourcery g++ lite for the tool chain.

I didnt condense the project as you mentioned, its not very complicated I'm sure you can follow it. Just a simple program to use with a nokia 5110 LCD.

Thank you, your help is very appreciated.

Tim

Tesla DeLorean
Guru
July 15, 2012
Posted on July 15, 2012 at 15:04

The most apparent problem is that you're using C++ which mangles the function names, and means the name for your IRQ does not match the name in the vector table.

You should be able to fix this using an explicit C declaration of the function. Or you could just use .C/.H files if you're not using C++, or place the interrupt code in the stm32f0xx_it.c file.

///DMA interrupt routine

void cdecl SPI_PORT_DMA_TX_IRQHandler() {

..

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
timotet
timotetAuthor
Associate II
July 17, 2012
Posted on July 17, 2012 at 02:14

clive 1

Thanks for your help.

I edited the code to C and moved the DMA interrupt to the

stm32f0xx_it.c file and DMA is working great.

I had tried to move the interrupt code before and it made no difference.

After reading your post, I tried changing the interrupt to :

void cdecl SPI_PORT_DMA_TX_IRQHandler()

That didnt work either. What exactly is the cdecl supposed do?

Why does C++ not work?

thanks again

Tim