3 Replies Latest reply on Nov 22, 2017 1:21 AM by martin.warkentin_1613731

    SPI - Communicate with more than 4 Byte in TxBuffer

    martin.warkentin_1613731

      Hello everyone,

       

      I want to build up a communication between a raspberry pi and a psoc 5LP via SPI 2MHz Clock with 6 Bytes.

       

      In my test programm the psoc should only send the 6 Test Bytes like: 0x11,0x22,0x33,0x44,0x55,0x66

       

      But the oszilloskop shows me, that the psoc sends the bytes in the wrong order... sometimes the same byte twize like:

       

      0x11,0x55,0x44,0x66,0x55,0x22

      or

      0x55,0x66,0x11,0x33,0x55,0x66

       

      When i change the TX Buffer Size down to 4 and just send Bytes 0x11,0x22,0x33,0x44 everything is correct and the psoc doesnt make any mistakes....

       

      I think it is a problem with the interrupts of the Fifo... maybe the psoc handles the interrupt to shift the bytes to the fifo to slow ?

       

      Best regards,

      Martin

        • 1. Re: SPI - Communicate with more than 4 Byte in TxBuffer
          hima

          Hello,

           

          Can you post your code snippet here?

           

          Thanks,

          Hima

          • 2. Re: SPI - Communicate with more than 4 Byte in TxBuffer
            martin.warkentin_1613731

            i could upload the complete project, but there are some other programms in the project, so it could be confusing ...

             

            for the spi communication i just do this ( copy from main ):

             

            //***********************************************************************************************

            // Main Funktion

            //***********************************************************************************************

            int main()

            {

                /* Start Komponenten */

               

                SPIS_1_Start();

             

                isr_spi_trigger_StartEx(Trigger_ISR);  // Trigger Pin from Raspberry Pi that set SPI_TRIGGER=1

             

                CyGlobalIntEnable;

               

                /* Loop forever */

                for(;;)

                {       

                    if(SPI_TRIGGER)

                    {

                       

                        SPIS_1_WriteTxDataZero(0x11);

                        SPIS_1_WriteTxData(0x22);

                        SPIS_1_WriteTxData(0x33);

                        SPIS_1_WriteTxData(0x44);

                        //SPIS_1_WriteTxData(0x55);

                        //SPIS_1_WriteTxData(0x66);

                        while(!(SPIS_1_ReadTxStatus() & SPIS_1_STS_SPI_DONE))

                        {

                        }

                        SPI_TRIGGER=0;

                    }

                }

            }

            /* End of main */

            • 3. Re: SPI - Communicate with more than 4 Byte in TxBuffer
              martin.warkentin_1613731

              noone an idea, why the psoc sends the wrong order or sometimes the same byte ? ( i have upload the complete project )

               

              timing problems ?

               

              I could change the program and divide the spi communication into 2 packages ... like :

               

              Package 1

              0x11

              0x22

              0x33

              0x44

              .

              ... time delay

              .

              Package 2

              0x55

              0x66

               

              Edit: I found the problem. It is the interrupt "Interrupt On Rx FIFO Not Empty"... when i set the

              Rx Buffer Size 4

              Tx Buffer Size 6

              everything works well.