Skip to main content
iforce2d
Associate III
September 30, 2020
Solved

Possible to disable SPI clock output?

  • September 30, 2020
  • 6 replies
  • 1689 views

I'm using SPI to output a signal for addressable RGB LEDs, as described here. https://innomatic.home.blog/2018/12/24/ws2812sk6812-control-with-spi-and-dma/

Since this signal requires only the MOSI pin, it would be great to be able to use the CLK pin for other purposes.

I tried omitting the CLK pin from HAL_GPIO_Init, which resulted in no clock signal showing on that pin. But that doesn't help when I want to use it for GPIO myself.  Is it possible to completely disconnect the external pin from SPI CLK?

This topic has been closed for replies.
Best answer by waclawek.jan

Yes, if you use only MOSI.

JW

6 replies

waclawek.jan
waclawek.janBest answer
Super User
September 30, 2020

Yes, if you use only MOSI.

JW

iforce2d
iforce2dAuthor
Associate III
September 30, 2020

Thanks. Maybe I should rephrase the question though - how would I do that?

waclawek.jan
Super User
September 30, 2020

Best by avoiding Cube/CubeMX. These are intended for the "usual"cases, whatever out of the scope of the authors means they get into way more than help.

Set required pin settings in respective GPIO registers, start with MODER.

JW

TDK
September 30, 2020

If you go into the "stm32*_hal_msp.c" file, edit the SPI initialization function to have it not initialize the SCK pin. You could leave the generated code alone and just add a de-initialization in the user code section.

"If you feel a post has answered your question, please click ""Accept as Solution""."
iforce2d
iforce2dAuthor
Associate III
October 2, 2020

Thanks for the responses. After reading around and experimenting with this a bit more, I realized that as long as I only want to re-use the CLK pin for GPIO, it's ok. I just can't use it for any different 'alternate function'.

Specifically, instead of GPIO_MODE_AF_PP I'm using GPIO_MODE_OUTPUT_PP.

I found this information helpful, in particular the diagram on page 7 https://www.hobbielektronika.hu/forum/getfile.php?id=278160

waclawek.jan
Super User
October 2, 2020

> I just can't use it for any different 'alternate function'.

There's no reason why you couldn't.

JW