Skip to main content
iforce2d
Associate III
Sep 30, 2020 3:18 PM UTC
Solved

Possible to disable SPI clock output?

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.
waclawek.jan
waclawek.janBest answer
Super User
Sep 30, 2020 3:52 PM UTC

Yes, if you use only MOSI.

JW

6 replies

waclawek.jan
waclawek.janBest answer
Super User
Sep 30, 2020 3:52 PM UTC

Yes, if you use only MOSI.

JW

iforce2d
iforce2dAuthor
Associate III
Sep 30, 2020 4:46 PM UTC

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

waclawek.jan
Super User
Sep 30, 2020 7:04 PM UTC

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
Sep 30, 2020 10:25 PM UTC

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
Oct 2, 2020 3:13 AM UTC

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
Oct 2, 2020 7:07 AM UTC

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

There's no reason why you couldn't.

JW