I'm a newbe here, so I thought I should try my luck
solving a basic simple problem of mine.
I have configured two controllers, HCS12C128, to communicate on the SPI. One as master, and the other as slave.
My problem is that I can't figure out how to return data from the slave.
I read the status register and then write to the data register, as the manual says, but I always receive the previously transmitted data in the master.
Thanks in advance,
How did you set your other SPI registers? I'm thinking I might be missing a bit setting somewhere.
Posted: Mon Apr 25, 2005 6:16 am
I keep the slave pulled down all the time.
In the master, the SPE, MSTR, and CPHA-bits of SPICR1 are set. SPICR0 is 0. I set the SPTIE and SPIE- bits right after the first byte is transmitted.
In the slave, the SPIE, SPE, MSTR, and CPHA-bits are set. SPICR0 is 0.
I also found that the slave data does not clock its data until the third byte. Maybe there's something I have missed that causes this, but I can live with it. I use sync and key data to detect messages anyway.
Moreover, you have to make sure that both ends are initialised before transmission begins.