cancel
Showing results for 
Search instead for 
Did you mean: 

How to write on external IC's registers connected to the SPI2 line of STM32F407VG MCU?

Lorenzo Estienne
Associate II
Posted on December 09, 2017 at 12:46

Hello everybody,

I need to write some registers of an integrated circuit connected to an STM32F407VG MCU by the SPI2 line.

I found these two functions:

     -SPI_I2S_ReceiveData()

     -SPI_I2S_SendData()

which documentation can be found at

http://www.disca.upv.es/aperles/arm_cortex_m3/curset/STM32F4xx_DSP_StdPeriph_Lib_V1.0.1/html/group___s_p_i___group2.html

I just didn't get how to tell the function which register I want to write to, since the SPI_I2S_SendData() accepts only 2 parameters: SPI line number (e.g. SPI1, SPI2, SPI3) and the data to be transmitted.

Any help is highly appreciated.

Thank you,

best regards,

Lorenzo

#register #spi #firmware #data
1 ACCEPTED SOLUTION

Accepted Solutions
Andrew Neil
Evangelist
Posted on December 09, 2017 at 19:16

Lorenzo Estienne wrote:

I just didn't get how to tell the function which register I want to write to, since the SPI_I2S_SendData() accepts only 2 parameters: SPI line number (e.g. SPI1, SPI2, SPI3) and the data to be transmitted.

That's because SPI has no definition of 'registers' or 'addresses' - it's all just data.

It's only your mystery '

integrated circuit' that assigns meaning to those bytes.

As  ​ (or is it ​) says, you'll have to study the datasheet of your mystery '

integrated circuit'  to find the required format for the data ...

View solution in original post

5 REPLIES 5
Posted on December 09, 2017 at 13:35

Read the external chip's datasheet. It should tell you what data to send in order to write to its registers.

JW

Andrew Neil
Evangelist
Posted on December 09, 2017 at 19:16

Lorenzo Estienne wrote:

I just didn't get how to tell the function which register I want to write to, since the SPI_I2S_SendData() accepts only 2 parameters: SPI line number (e.g. SPI1, SPI2, SPI3) and the data to be transmitted.

That's because SPI has no definition of 'registers' or 'addresses' - it's all just data.

It's only your mystery '

integrated circuit' that assigns meaning to those bytes.

As  ​ (or is it ​) says, you'll have to study the datasheet of your mystery '

integrated circuit'  to find the required format for the data ...

Lorenzo Estienne
Associate II
Posted on December 09, 2017 at 21:43

Thank you both!

I firstly had to use the SPI_I2S_SendData() function to select the register, and THEN use it again to tell the data I wanted to write on the register I previously chosen.

Lorenzo Estienne
Associate II
Posted on December 09, 2017 at 21:54

I've created a function that takes as arguments the SPI line, the register, and the data that I want to write.

Then this function executed the SPI_I2S_SendData() twice.

Posted on December 09, 2017 at 21:52

are you sure you couldn't do it all in one?