Hi,
I have a peripheral which needs to change the SPI clock frequency after writing a command to it, the same is shown in the below figure.
Is there a simple way to do this with TI libraries?
Thank you,
Kishore.
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.
Hi,
I have a peripheral which needs to change the SPI clock frequency after writing a command to it, the same is shown in the below figure.
Is there a simple way to do this with TI libraries?
Thank you,
Kishore.
Hi Kishore,
To switch the SPI clock speed, you will need to first close and then reopen the SPI interface with the new clock rate. This can be done by changing .bitRate in your SPI open parameters.
Since you mentioned that the CS signal must not be de-asserted during the switch, the simplest way to ensure that is to make the CS signal a SW controlled GPIO. To do so, set the SPI peripheral into 3 wire mode, with SW controlled CS. The SPI CS settings are done in CC3200SF_LAUNCHXL.c, in the spiCC3220SDMAHWAttrs struct. Please use the following settings:
{ .baseAddr = GSPI_BASE, .intNum = INT_GSPI, .intPriority = (~0), .spiPRCM = PRCM_GSPI, .csControl = SPI_SW_CTRL_CS, .csPolarity = SPI_CS_ACTIVELOW, .pinMode = SPI_3PIN_MODE, .turboMode = SPI_TURBO_OFF, .scratchBufPtr = &spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPI1], .defaultTxBufValue = 0, .rxChannelIndex = UDMA_CH6_GSPI_RX, .txChannelIndex = UDMA_CH7_GSPI_TX, .minDmaTransferSize = 10, .mosiPin = SPICC32XXDMA_PIN_07_MOSI, .misoPin = SPICC32XXDMA_PIN_06_MISO, .clkPin = SPICC32XXDMA_PIN_05_CLK, .csPin = SPICC32XXDMA_PIN_NO_CONFIG }
Then, configure a GPIO in the gpioPinConfigs struct of the same file. If you wanted to keep CS on pin8, then configure GPIO17 as an output. With that, you can use a GPIO_write() to assert CS when needed in your code.
Let me know if you need more clarification or have further questions on this topic.
Regards,
Michael
Hi Michael,
1) I am using pin 5 (GPIO_14 ) as my SPI clock, can I produce PWM waveform on this pin.
If I can use PWM on the same line, please suggest how can I do it.
2) Another way is, Instead of using SPI libraries, I am using all 4 pins as GPIOs. I am able to write and read data, mainly I can vary clock just after writing 0xC2 command, the problem with this is the GPIO toggling is it's not consistent, I am not meeting the timing, my requirement is, I need 32us for each cycle. sometimes I am getting 32us and sometimes I am getting 31.8us.
Please see the below snapshots for the same
The delay in the code is the same between the toggles. still, I see the time differences.
Is it because of the latencies added by GPIO_toggle function. If so can you suggest me any alternate methods?
Thank you,
Kishore.