Problem with SPIM, I can't receive anything

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

cross mob
Anonymous
Not applicable

Sorry, I just solved my problem while gathering the data to get support but the solution creates another question for me, why does what I explain below happen when I use a buffer superior to 4 bytes? I know the SPIM have a 4byte hardware buffer but why it doesn't work when using software buffer? I had the SPIM configured for 28 bytes.

   

 

   

Thank you.

   

 

   

My post:

   

Hi,

   

I'm interfacing the PSOC 4 with an ADS1298. I'm trying to get some that out of the ADS1298 so I only have to provide clock to it to receive some of the data.

   

I do that correctly and it sends data since I can see it in the scope. The problem is that I can't read any data with the SPIM.

   

This is the loop where I keep receiving data.

   

 

   

SPIM_1_Start();

   

    for(;;)

   

    {

   

        if(DRDY_Read()==0){

   

for(i=0; i<27;i++){

   

SPIM_1_WriteByte(0);

   

while(!(SPIM_1_ReadTxStatus() & SPIM_1_STS_SPI_DONE));

   

// CyDelayUs(10);

   

while(!(SPIM_1_ReadRxStatus() & SPIM_1_STS_RX_FIFO_NOT_EMPTY));

   

if(SPIM_1_GetRxBufferSize()>0)

   

payload = SPIM_1_ReadRxData(); 

   

//UART_UartPutChar(payload );

   

}

   

}

   

}

   

 

   

If tried commeting the first while and the second or adding the delay with no luck.  If I don't comment the if(SPIM_1_GetRxBufferSize()>0)  it gets stuck there because it is not reading anything but it is receiving data since I can see it with my scope.

   

 

   

The solution was to change the RX buffer size to 4.

0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked
        When having more than 4 bytes an internal interrupt will be used to read off the received bytes from the Tx-buffer. Only chance is to poll the buffer for characters received with SPIM_GetRxBufferSize().   
   
Bob   
0 Likes
Anonymous
Not applicable

 Thank you Bob.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked
        You are always welcome!   
   
Bob   
0 Likes