Possible to disable SPI clock output?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-09-30 8:18 AM
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?
Solved! Go to Solution.
- Labels:
-
SPI
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-09-30 8:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-09-30 8:52 AM
Yes, if you use only MOSI.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-09-30 9:46 AM
Thanks. Maybe I should rephrase the question though - how would I do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-09-30 12:04 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-09-30 3:25 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-01 8:13 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-02 12:07 AM
> I just can't use it for any different 'alternate function'.
There's no reason why you couldn't.
JW
