cancel
Showing results for 
Search instead for 
Did you mean: 

Possible to disable SPI clock output?

iforce2d
Associate III

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?

1 ACCEPTED SOLUTION

Accepted Solutions

Yes, if you use only MOSI.

JW

View solution in original post

6 REPLIES 6

Yes, if you use only MOSI.

JW

iforce2d
Associate III

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

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
Guru

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
Associate III

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

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

There's no reason why you couldn't.

JW