3 Replies Latest reply on Apr 15, 2016 11:12 AM by user_78878863

    SPI - MASTER

    aditya.karn
              Hi All, I am using SPIM component. I want to read back the MISO data. Using logic analyzer i can see the data. But how to store that data in any variables??? please see my code for your reference. Please let me know what modification is needed. SPIM_WriteTxData(Control_Byte); SPIM_WriteTxData(0); SPIM_WriteTxData(0); while(!(SPIM_ReadTxStatus() & SPIM_STS_SPI_DONE)){} while (SPIM_GetRxBufferSize()==0); u8RSUAdcValue1=(uint8) SPIM_ReadRxData(); //always returns the value 0. ???   
        • 1. Re: SPI - MASTER
          user_1377889

          You have to expect 3 bytes : one as the return of sending the command byte and two bytes for the sent zeroes. Because sending and receiving runs in parallel in SPI conversions you can be sure that after the while(!(SPIM_ReadTxStatus() & SPIM_STS_SPI_DONE)){}

             

          your SPIM_GetRxBufferSize() returns 3.

             

          And for heavens sake use someting like

             

          #define Wait(x)

             

          ...

             

          while (SPIM_GetRxBufferSize()==0) Wait();

             

          That will be quite better readable than just a semicolon.. 

             

           

             

          Bob

          • 2. Re: SPI - MASTER
            user_78878863

            Whenever a SPI master writes a value, it also read a value back in. So when you send the Control_Byte, the master reads a value which contains a dummy value. You need to throw this away. So only the second byte you read is valid.

            • 3. Re: SPI - MASTER
              martin.gonzalez71_1573081

              Hi Bob

                 

               

                 

              Could you help me with the PSoC 5 LP and Arducam mini Communication device, I don't understand how to do the Inicialitacion of Protocol SPI and verify the response of arducam 

                 

               

                 

              Thank you