cancel
Showing results for 
Search instead for 
Did you mean: 

SPI FULL Duplex Slave ; receive data, but not transmission

Roibert
Associate II

Dear Forum

Im using the SPI of STM32 H7 43ZI.

-In master mode,full duplex, not problem: Transmit and receive data precisely, up to 2Mbit/sec (limits come from cable lenght) .Each pack is 24 bytes.

-In slave mode, this is what i do  (master at 200Kbit/sec): 

 a)FIFO LEVEL=2 BYTES

  b)Master send 2 bytes . The STM32 Slave Receive this 2 byte , and INT roudine is activate

   c) save in a buffer , and load 2 byte to be TX.

And repeat,  up to 24 bytes. 

Problem is:

     *  I get 24bytes ok

     *no data are trasmitted.. MISO is fix to low 

The simplified version of code is this:

 

 

//SPI3 Slave
uint8_t *p_TXDR_SPI3= &(SPI3->TXDR);
uint8_t *p_RXDR_SPI3= &(SPI3->RXDR);

void INT_SPI_3_RXTX_8BIT(SPI_HandleTypeDef *hspi3)
{
    if (  (   (SPI3->SR )  & (  SPI_FLAG_RXP)  )!=0)
    {
         //Save the RX data
         ArrGenRx[IndRx]=*p_RXDR_SPI3;
           IndRx++;

          ArrGenRx[IndRx]=*p_RXDR_SPI3;
          IndRx++;

          Len_Data=Len_Data-2;

          //End Msg ?
           if(Len_Data==0)
           {
                Len_Data=24;
                ...
                IndRx=0;
                IndTx=0;
            }
  
            else
            {
                //Load data to be TX; normally comes from a Array, but for simplify
                //i send costant
                *p_TXDR_SPI3=0xAA;
                IndTx++;
 
               *p_TXDR_SPI3=0xBB;
                IndTx++;
             }

           }//RXP INT ??

}​

 

Also changing the MISO pin, nothing change.

Thanks for any help

Roberto

 

 

2 REPLIES 2
KDJEM.1
ST Employee

Hello @Roibert ,

 

I apologie for my late reply.

If the issue is not solved yet, could you pleas check the SS pin because, in slave mode, the SS works as a standard ‘chip select’ input and lets the slave communicate with the master.

I recommend you also to refer to STM32CubeH7/Projects/NUCLEO-H743ZI/Examples/SPI/SPI_FullDuplex_ComPolling at master · STMicroelectronics/STM32CubeH7 · GitHub example may help you.

 

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Andrew Neil
Super User

@Roibert wrote:

-In slave mode, this is what i do  (master at 200Kbit/sec): 


What is the Master?

Please show your schematic - see:How to write your question to maximize your chances to find a solution.

 


@Roibert wrote:

     *no data are trasmitted.. MISO is fix to low 


Can you drive the pin high and low when it's just configured as a GPIO - no SPI ?

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.