cancel
Showing results for 
Search instead for 
Did you mean: 

SPI troubles

Stoufer
Associate III

Hi - I have a new board with very minimal parts other than a STM32L451VET6 micro and a SPI LCD.

I have implemented SPI and the micro is sending data when I single step the program. When I just let it run it Sends exactly three and one half bytes... every time. I am using the following code :

HAL_GPIO_WritePin(DISP_CS_GPIO_Port, DISP_CS_Pin, GPIO_PIN_RESET); // set CS low
HAL_SPI_Transmit(&hspi1, (uint8_t *)&spi_init_cmds_new, 18, 100); // write init data to display
HAL_GPIO_WritePin(DISP_CS_GPIO_Port, DISP_CS_Pin, GPIO_PIN_SET); // set CS high
 
it seems like some sort of timing issue because it will single step and send two bytes at a time with CS toggling between them as it should. It setup for Master transmit only since my display doesn't have a read function.
I set the internal clock (MSI RC ) to 8000 with a SPI prescaler of 128  for a baud of 62.5kbits. Here is the SPI config : 
Stoufer_0-1693261406115.png

for testing I added a HAL_Delay(500); line right after the SPI write and when single stepping it locked up on that line...

Any ideas are appreciated !!

Thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

You could try initializing it in two-line mode and leave MISO disconnected. I don't think there are bugs/issues in master transmit-only like there are for receive-only, but there could be.

Would be nice to see more of the relevant code and traces of the signals you're seeing, make sure word size is configured correctly.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

4 REPLIES 4
Pavel A.
Evangelist III

HAL_GPIO_WritePin(DISP_CS_GPIO_Port, DISP_CS_Pin, GPIO_PIN_RESET); // set CS low

Why is this? You've configured hardware NSS output on PB0. Is DISP_CS defined as PB0?

 

TDK
Guru

You could try initializing it in two-line mode and leave MISO disconnected. I don't think there are bugs/issues in master transmit-only like there are for receive-only, but there could be.

Would be nice to see more of the relevant code and traces of the signals you're seeing, make sure word size is configured correctly.

If you feel a post has answered your question, please click "Accept as Solution".

yes 

Stoufer
Associate III

Its fixed! I had tried using Master Full-Duplex yesterday. But before I was using NSS hardware output.

So ... using NSS hardware out, and setting it for Master full-duplex is now working.

Thanks Guys !!