cancel
Showing results for 
Search instead for 
Did you mean: 

Strange SPI problem

love-peace2001
Associate II
Posted on March 24, 2014 at 11:47

Hello everybody,

I am trying to interface two STM32F3 boards with SPI port in full duplex with interruption.

One board acts as Master and the other one as a Slave.

The Master sends a command,  then the 4 Byte from TxBuffer.

When the slave receives this command, it enables the transmission buffer interrupt to send an ACK, then a

4 Byte from TxBuffer.

The problem is that the 4 Bytes sent by the slave, i received only 2 Bytes.

My BaudRate set up is : SPI_BaudRatePrescaler_8;

 

If i slow down this by putting : SPI_BaudRatePrescaler_256; i can receive 3 Bytes

You find  enclosed the code written for the Master and the Slave.

Thanks in advance of any help.

3 REPLIES 3
love-peace2001
Associate II
Posted on March 24, 2014 at 22:10

No idea what would be the problem ?

Please, i need an answer to continue my work .

Thanks

Posted on March 24, 2014 at 22:50

The code is frustratingly incomplete, but doesn't RXNE trail TXE, what's the consequence of disabling the TXE interrupt?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
love-peace2001
Associate II
Posted on March 27, 2014 at 17:16

Thank you clive1 for your response.

I have updated my code.

In the

SPISlave.c, i have created two functions

SPI_Receive()(receive data from the Master) and

SPI_Send()(send data to the master). These routines are called in a

Main function depending if i want to receive or send.

The

SPI_Receive() receives data from the SPI master with no problem. But when i want to send data to the master using the

SPI_Send(), i can't get data in the SPI master side.

In both

SPIMaster.c and

SPISlave.c, you can find how the

SPI1_IRQHandler() that makes the treatment.

Thanks in advance for helping.

________________

Attachments :

SPIMaster.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hzat&d=%2Fa%2F0X0000000bOB%2FtKDDztvh.NWX_LeGPeAYa991LdrsrMNOkrNm1ro5Tjw&asPdf=false

SPISlave.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hzao&d=%2Fa%2F0X0000000bOC%2FKB2.NyR3WjMS1g_121A_iSx7W5_PcFaSf20_H3YUWnU&asPdf=false