Jan-17-2022, 12:58 AM
(Jan-17-2022, 12:06 AM)bowlofred Wrote: Do you have an example of the bytes that you receive and know the specific integer that it should form?
Thanks for the reply. Yes, I need to convert it to little endian. On the slave side, I have for ex. 4094 as a 32bit integer. I convert it to 4 8-bit integers as below and then send it over to RP:
b1 = (unsigned int)(data_adc & 0xff); //data_adc is 32 bit integer b2 = (unsigned int)(data_adc >> 8) & 0xff; b3 = (unsigned int)(data_adc >> 16) & 0xff; b4 = (unsigned int)(data_adc >> 24); int testarray[4]={b1,b2,b3,b4}; for (int i = 0; i < 4; i++){ USART_SpiTransfer(USART0, testarray[i]); }So basically, when this data_adc is always 4094, the slave always sends [254,15,0,0] (checked using debugger on slave side). So, I should receive the same on Raspberry Pi.
In fact when I change the print statement to:
print (b)
I get this:
. . [15L, 224L, 0L, 0L] [0L, 0L, 253L, 224L] . .And these 2 lines are repeating instead of only repeating [254,15,0,0]. Any suggestion, what I might be doing wrong here?