I am trying to set my SPI communication with a PIC18F452 from Microchip in order to send an 8-byte array to the bus (= transfer of all the bytes at once). Here is an example of what my array looks like :
array 0x0080 byte[8]
array[0] 0x0080 0x01
array[1] 0x0081 0x01
array[2] 0x0082 '\0'
array[3] 0x0083 0x01
array[4] 0x0084 0x01
array[5] 0x0085 0x01
array[6] 0x0086 0x01
array[7] 0x0087 '\0'
The values are coming from an input signal (audio file, clock, etc.) and received on PORTDbits.RD0 to fulfill the array. The values are always 1 or 0 and nothing else.
First, I have started by sending one byte at the time with putcSPI(). As I fulfill the array, I send one byte to the SPI and the results are a match.
Then, I tried to send all the bytes at once, using putsSPI() like follow :
/// SEND DATA TO SPI
SPI_INT = 0; // Enable SS
putsSPI(array);
SPI_INT = 1; // Disable SS
delay_ms(); // Delay
But the transfer of the frame is stopped when I encounter a 0 (considered as end of array, so that's normal). And, my frame is divided into chunks.
e.g, for the array displayed above, I have on the SPI bus "1 1" and then, the next values are from the frames that follow
That being said, I thought of converting the data from binary to hexadecimal (or integer) and then send it to SPI. I have tried several methods of conversion found here, but until now none has been successful.
Is there a solution to send directly the full array to the bus, or does anyone have an idea on how to perform the conversion in this particular case ?
Many thanks in advance !