cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F401 SPI CLK not working

djerikos
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

5 REPLIES 5
djerikos
Associate II

Sorry guys forgot the photos

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
Up vote any posts that you find helpful, it shows what's working..
djerikos
Associate II

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

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);
}

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
Up vote any posts that you find helpful, it shows what's working..