SPIS RX buffer data incorrect

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

cross mob
Anonymous
Not applicable

Could someone provide a sanity check for me. I have an SPI slave module with an 8 bit word, 8 byte RX buffer, and an interrupt that triggers when the buffer is not empty. The interrupt toggles a flag which then executes :

   

if(SPIS_GetRxBufferSize() >7){         //wait until all 8 bytes of data have arrived
         x.b[0] = SPIS_ReadRxData() ;   //increment through the buffer
         x.b[1] = SPIS_ReadRxData() ;
         x.b[2] = SPIS_ReadRxData() ;
         x.b[3] = SPIS_ReadRxData() ;
         y.b[0] = SPIS_ReadRxData() ; 
         y.b[1] = SPIS_ReadRxData() ;
         y.b[2] = SPIS_ReadRxData() ;
         y.b[3] = SPIS_ReadRxData() ;
        
        SPIS_ClearRxBuffer();     //clear the buffer for the next set of data
        SPIS_ReadRxStatus();
 
   }

   

The issue I have today is that when I repeatedly send 0x0a and 0x0b (to test) the first byte is correct but then the rest are '05' (hexadecimal printout) (and for the next buffer all are 05). If I repeatedly send just one byte (0x0a for example) all bytes in the buffer are '0A' .This makes no sense to me. Is the code above correct? 

   

Thanks,

   

Evan

0 Likes
1 Reply
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Are you sure the SPI configuration matches between master and slave? Ist looks as if your slave is missing the first bit. Also, check that there is no crosstalk between your SPI lines (e.g. slave select and clock). Maybe check with a scope that you actually transmit what you think you transmit.

0 Likes