1 Reply Latest reply on Oct 29, 2020 12:12 PM by ApurvaS_36

    SPI Phase Change in Runtime


      Good morning! I am working on a project that uses two slave devices on different SPI clock phases. We are using the CYBLE-212006-01 as the master with two slaves. Slave(0) needs CPHA = 1 and CPOL = 0, slave (1) needs CPHA = 0 and CPOL = 0.


      I see another user had the same problem in 2015 and it was not solved: Change SPI CPHA/CPOL in runtime


      We are planning to develop a function that runs SPI for slave (0) until there is an interrupt for slave (1). Once this interrupt occurs, we will switch SPI clock mode to slave(1) device to read the data. To do this we plan on modifying the SPI_SpiSetSlaveSelectPolarity to change the clock mode instead of the slave select polarity in the SPI control register.


      Have you developed any code or projects to assist with this problem? Thank you for your help.

        • 1. Re: SPI Phase Change in Runtime



          I am not sure why you have chosen the SPI_SpiSetSlaveSelectPolarity API. This API allows you to choose slave select line polarity, means whether you want your slave select to be active low or active high.

          As per my understanding, in your case you will need to change the SPI clock modes since the two slaves are working on different clock phase and polarity. Please correct me if I am wrong.


          You can try using an Unconfigured SCB and configure it for SPI operation with CPHA = 1 and CPOL = 0 clock mode while using Slave (0) and reconfigure the SCB to SPI with CPHA = 0 and CPOL = 0 when there is an interrupt from Slave (1).

          Hope this helps. Unfortunately there is no sample project for this exact operation.


          - Apurva