This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Multiple Chip Selects on L137 SPI



We are using multiple devices on SPI 1, where SPI 1 is a master.  My interpretation of the architecture is that the L137 only supplies provides one chip select.  Is our design suppose to use SCS[0] as gating line for other GPIO lines that we would use to generate the chip selects.  Or can we just ignore it and use other GPIO instead.

Thanks.

  • Yes, there is only one chip select pin (SCS[0]) for SPI1.  You don't have to use SCS[0] if you don't want to.  If you are interfacing to multiple slaves, then it's okay  to use multiple GPIOs for chip selects. 

    Your sequence for using the SPI port will probably be something like: write to GPIO register to set GPIO low, write data to SPI transmit register or start EDMA transfer, wait for EDMA completion interrupt (assuming EDMA is used), write to GPIO register to setup GPIO high.  There is one caveat to this approach though. 

    The SPI transfer is not "done" when EDMA or CPU writes the last character to the SPI transmit register.  The SPI still has to shift out the data!  You don't want to set the GPIO high in the middle of a transfer.  Also, it may not be possible to use SW delays to get around this (the size of the delay depends on too many variables).  One good thing is that SPI always shifts data in as it shifts data out, so the CPU could wait until the receive flag is set on the last transfer to guarantee the SPI is done shifting out the last data.  There are also ways to implement this "workaround" when the EDMA is used.

  • Thanks for the info.  This is what I thought.  Nice info on detecting the transfer is complete.  I am sure that would have bit us for a few days.

    Thanks again.