Hello Dev, and welcome to the forum.
What happened to the formatting of your post? Always a good idea to check immediately after posting, and if necessary, edit your post.
I can't be sure about the validity of your virtual connection - others may need to assist here. But you may also need to consider the SS connection between master and slave (since the slave operation has set CPHA = 0).
I can see a number of problems with the code you have posted -
- You seem to have a mismatch between master and slave channels with respect to the control bits LSBFE and CPHA. This is not permissible.
- I would assume that you intend to operate with automatic operation of the master SS line as an output (SSOE = 1). This also requires that MODFEN = 1 (SPI0CR2 = 0x10).
- Even though you are not using the return data from the slave channel, you will still need to clear the flag to prevent an overrun condition. This will require SPI0DR to be read.
- While not a problem per se, be aware that setting the baud rate for the slave channel fulfills no purpose. The master will determine the clock rate at which the slave operates.
Part of the modified code is reflected below -.
while (!SPI0SR_SPTEF );
SPI0DR = 0x78; /* Send byte to master */
while (!SPI0SR_SPIF); /* Wait for transmission complete */
i = SPI0DR; /* Clear flag for master */
while (!SPI1SR_SPIF); /* Clear flag for slave */
i = SPI1DR; /* Byte value received by slave */
Regards,
Mac