cancel
Showing results for 
Search instead for 
Did you mean: 

From I2C to SPI using the DMA (STM32F0)

Nickname925_O
Associate II
Posted on September 25, 2013 at 11:33

Hello everybody,

I have to communicate with a STM32F0 using the I2C and then, the STM32F0 has to communicate with another device through the SPI?

Is it possible to implement it through the DMA?

If yyes, do you have working code?

Thanks a lot in advance!

#spi #stm32 #i2c #discovery #stm32f0
3 REPLIES 3
dibs
Associate II
Posted on September 26, 2013 at 06:34

Yes, this is possible. What I would suggest is to find a library that you like that has plenty of examples. For instance I use the CMISS V1.2 library and generally use the examples that are meant for the Discovery development kit.

What you will probably want to do is to set up a DMA channel to write your I2C input to memory. There are various options for doing the second half of your transfer, dependent on your unique application.

Is the mcu going to be merely a bridge between these two devices? Do you need to put the data into a specific packet? Do you need to buffer the data and send upon request? These (and more) questions will control your end implementation.

If all you want is a continuous bridge, the I would set up your input DMA stream ISR to write directly to the output data register. This would work best if you were expecting a continuous or frequent data stream from your input.

There are many more options, such as double buffering, that will most likely give you the flexibility to give you what you want.

Again, respond back with more details if you want more advice.

Nickname925_O
Associate II
Posted on September 26, 2013 at 09:21

Hi Naphtali,

thanks a lot for your help.

Well, about the data streaming from I2C->SPI and viceversa, the mcu is a simple continuous bridge between this 2 devices.

So, I guess that I2C_DMA-memory and then DMA-memory_I2C and viceversa it's enough.

I am looking forward to see your ''code''.

Thanks a lot in advance.

PS: please, just to be sure, can you send me the link about the library you referred in your last post?

Nickname925_O
Associate II
Posted on October 01, 2013 at 07:51

Hello everybody,

please, can you help me to implement an I2C2SPI or SPI2SPI using the DMA?

Thanks in advance :)