SPI - Communicate with more than 4 Byte in TxBuffer

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

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.

View solution in original post

0 Likes
3 Replies
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

Hello,

Can you post your code snippet here?

Thanks,

Hima

0 Likes
Anonymous
Not applicable

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 */

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

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.

0 Likes