Hi everyone!
This issue could been seen as a continuation of a previous thread I started here a month ago however I feel a new thread should be started as the issue remains after going through my code to make sure I have not inadvertently changed or left out any of the code recommended in said thread. If a moderator feels disagrees please append this to my previous thread.
The Background:
I've been working on getting a PIC18 (set as master) to communicate with a TMS570 (slave). The aim of the exercise is to have the PIC18 periodically request data from the TMS570, where all data packets will be 4 bytes long.
In order to do this an interrupt routine has been set up on the TMS570 where when the PIC18 pulls RB1 high the TMS570 gets ready to receive a 4 byte telecommand, the TMS570 then informs the PIC18 it is ready to receive by pulling another RB2 high.
As all telecommands will result in a response from the TMS570 the PIC18 has been coded to wait until RB2 is pulled high a second time to indicate that the TMS570 is now ready to send data back.
In the case I have provided below it is a simple routine to inform the PIC18 that the TMS570 is operational (it will be expanded further to include error codes once this issue is resolved)
The problem:
So to recap the TMS570 receives all bytes sent by the PIC18, both the Telecommand and the junk bytes sent to stimulate the SPI for the return data, however the PIC18 seems to miss the first byte of each packet sent by the TMS570. The data return routine is based on the fact that the TMS570 can not send data until the SPI clock is started again and the first byte from PIC18 is sent. With this in mind the TMS570 places the data into its SPI buffer, then "starts" its transfer (however as the Master has not started the transfer TMS570 will wait) pulls the GIO high and then polls the transfer complete flag. As for the PIC18 while the TMS570 is preparing its response the PIC18 makes its way to the SPI receive function I've set up, waits until RB2 is pulled high and then starts the SPI transfer immediately.
Can you see any errors I have made in my code/logic which would result in the PIC18 missing the first byte sent by the TMS570?
Thanks in advance
Alex