KE02Z - SPI Daisy Chain

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KE02Z - SPI Daisy Chain

673 Views
lmg
Contributor III

I'm attempting to connect several KE02Z's (FRDM-KE02Z40M board) in a daisy chain. One will be the master, the others will be the slaves.

I am using KDS 3.1.0 and Processor Expert.

For each slave, MISO is connected to the next downstream slave MOSI.

Clock from master goes to all slaves. All slaves have SS tied low.

I am using the multi-byte transmit method SendBlock().

What I expected:

     I thought that a series of bytes transmitted by the master would "ripple through" the slaves. Each slave would simply shift out the byte just received - just delayed by one byte time.

What I observed:

     It appears that the contents of the SPI shift register is transferred to the receive buffer after each complete byte is received and that the contents of the transmit buffer is transferred into the SPI shift register. So the byte that just arrived gets overwritten. As the clock from the master continues, it's not the original data from the master that gets shifted out, but data from the slave's transmit buffer (which seems to be zero by default).

Possible workaround:

     I could do everything one byte at a time. Master transmits one byte. Then each slave could copy the byte just received into its own transmit buffer. Then master can transmit the next byte, etc.

Is there a cleaner way to do this - perhaps with built-in methods?

Thanks.

~LMG

0 Kudos
1 Reply

365 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

If you use SPI function of SDK or PE, for example using SPI_DRV_SlaveTransferBlocking() or using SPI_DRV_SlaveTransfer() functions, the mechanism is that you you send your buffer to the SPI buffer, the SPI will transfer one by one in the SPI buffer in interrupt mode, You can not transfer one byte with your own control.

If you want to transfer one byte with your control, in other words,you know which byte you are transferring, you can not call the SPI function the SDK or PE provides, you have to initialize the SPI module yourself, then write the SPI0_D register, poll the SPI status register or use interrupt mode to read/write data.

Hope it can help you.

BR

Xiangjun Rong

0 Kudos