Skip to main content
Associate
November 9, 2023
Solved

STM32F401 SPI CLK not working

Hi guys,

I'm currently working on a project where I need to use the SPI protocol. 

After setting everything up in the .ioc file and generating the code. I wanted to check if the clock signal was properly working. So i hooked up my ossciloscop to the clk pin. To my surprise there was nog clk signal being generated.

 

I've attached a few pictures of the ioc view asswel as the code.

Could you guys help me out on this one?

 

Kind regards Erik

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
November 9, 2023

Incrementing from 23 to the integer limit. Probably getting a Hard Fault and not getting to the HAL_SPI_Transmit() at all.

Hint: not i++

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

5 replies

djerikosAuthor
Associate
November 9, 2023

Sorry guys forgot the photos

Tesla DeLorean
Guru
November 9, 2023

You'll need to be Transmitting something to get clocks.

It would be more helpful to show the code configuring the SPI, peripherals, pins, clocks, and the code transmitting, perhaps a 0x55 pattern, in a continuous loop.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
djerikosAuthor
Associate
November 9, 2023

These are the files with the code, i'm trying to build the same project as Controllerstech in this video:

https://www.youtube.com/watch?v=71SRVEcbEwc

Chris21
Associate II
November 9, 2023

The for loop in this function doesn't look too good...

 

void ws2812_spi (int GREEN, int RED, int BLUE)
{
	uint32_t color = GREEN<<16 | RED <<8 | BLUE;
	uint8_t sendData[24];
	int indx = 0;

	for (int i=23; i>=0; i++)
	{
		if(((color>>i)&0x01) == 1) sendData[indx++] = 0b110;
		else sendData[indx++] = 0b100;
	}

	HAL_SPI_Transmit(&hspi1, sendData, 24, 1000);
}

.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
November 9, 2023

Incrementing from 23 to the integer limit. Probably getting a Hard Fault and not getting to the HAL_SPI_Transmit() at all.

Hint: not i++

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..