cancel
Showing results for 
Search instead for 
Did you mean: 

How to disable and enable SPI SCK inside interrupt handler?

LJarv.1
Associate

Hi,

I'm trying to communicate with a device that requires few microsecond pause between SPI read and write access. During the pause, SCK and CS line must be kept low. Please note, that I want to use SPI in interrupt driven mode. MCU is STM32F7x7

Currently, there is a workaround inside the SPI_IRQHandler where we direct the SCK to another alternate pin for one "dummy" byte between the write and read and put the original SCK pin to output for the duration of the dummy byte, but this is not the most ideal way...

I would like to just disable the SCK pin for one byte and essentially send "0x00" using only MOSI, but seems like putting the SCK to output without any other pin functioning as alternate SCK output disables the SPI peripheral.

Is there a proper sequence to disable SCK and keep the SPI alive or could there be another approach to archive the needed delay? Note, that if the delay is done outside the IRQHandler, it would affect other task running on the RTOS.

2 REPLIES 2

> I would like to just disable the SCK pin for one byte and essentially send "0x00" using only MOSI, but seems like putting the SCK to output without any other pin functioning as alternate SCK output disables the SPI peripheral.

SPI's receiver needs "feedback" from physical SCK, but you should be able to Tx and then observe BSY to find out that one frame has finished.

You can also use a timer to time the delay.

JW

TDK
Guru

I don't think you'll find a way to do this automatically. Surely the OS has a non-blocking delay you could be using. SCK only goes when the peripheral has bytes to send, or receive is enabled, so simply hold off on sending those until ready.

If you feel a post has answered your question, please click "Accept as Solution".