AnsweredAssumed Answered

S12X SPI Protocol Issues

Question asked by Bhavya C on Oct 21, 2013
Latest reply on Oct 29, 2013 by Edward Karpicz

Hello,

 

I am using a S12X (MC9S12XS256) controller with CodeWarrior v5.9.0.

I am using the SPI port to communicate with a DSP(ADAU1701).

My SPI runs in the single byte mode with CPHA = 0 and CPOL = 0 and is the Master device.

After much trouble I have finally managed to init the DSP in SPI mode and write a couple of bytes to the Core Register. (i verified this by using an external debugger for the DSP)

 

My issue is that I have been having trouble in reading from the DSP.

In order to read, the DSP expects 3 bytes of input data to start with; 1st byte is a 7-bit chip address + a single bit read/write command (0-write and 1-read; this bit is the LSB), 2nd byte is the higher byte of the register address and 3rd byte is the lower byte of the register address. After it receives these bytes, the DSP should transmit the content of the register.

I however read only 0xFFs on the controller!!

 

After a thorough look into the reference manual for the controller in question, i found the below statement...

"During an SPI transmission, data is transmitted (shifted out serially) and received (shifted in serially)

simultaneously. The serial clock (SCK) synchronizes shifting and sampling of the information on the two

serial data lines."

I have also seen several similar explanations in different threads in the forum.

 

Does this mean that I have to read as soon as I send bytes to the slave device since it is simultaneous transmission?

But this wont work, since the DSP needs the 3 bytes in order to send anything. Even if the DSP is ready to send the content of the register (or any data for that matter) after it has received the address, it cannot do so since the SCK stops after all the bytes are transmitted (because of simultaneous transmission) and so all that I would read is junk!

..and so I am stuck!

 

Request someone to clarify and help me out this.

 

Thanks in advance.

- Bhavya

Outcomes