cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103C8 using SPI2

hamo
Senior

Hello,

i am trying to interface 1.8 inch SPI TFT Display 128 x 160 to the STM32F103C8 using SPI2.

https://www.az-delivery.de/products/1-8-zoll-spi-tft-display

SPI1 is used for LoRa, i thought to connect TFT too to SPI1 using addresses but i am affraid to influence the

LoRa.

The library which i am using is from this website:
https://controllerstech.com/st7735-1-8-tft-display-with-stm32/

A year earlier i tried to interface LoRa to STM32F103C8 using SPI2 but without success.

Is it a general problem in STM32F103C8 using SPI2?

Any help is appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
hamo
Senior

The problem was with the hardware.
Finally i could get the SPI2 work together with SPI1 on the same Board.
Many Bluepills are just not good this days.

Anyway thank you all for being helpful.

Best regards

Mohamad

View solution in original post

65 REPLIES 65
Andrew Neil
Evangelist III

@hamo wrote:

Is it a general problem in STM32F103C8 using SPI2?


No - it shouldn't be.

hamo
Senior

Then what is the problem

Here is how i configured the stm32f103 usnig STM32CubeMX:

SPI2.JPG


@hamo wrote:

Then what is the problem


No idea!

All you've said is that you failed with it previously - we have no way to tell what you were doing wrong.

What debugging did you do? What did you discover?

 

hamo
Senior

Has someone had success with SPI2 interfacing anything to stm32?

I am using KEIL IDE, it freezes as soon as it reaches HAL_SPI_Transmit().

No idea why?

So, again, what debugging have you done to find why it's freezing?

Have you stepped into  HAL_SPI_Transmit() to see what's happening ?

Have you looked at the SPI lines to see what's happening?


hamo
Senior

No, i stoped by HAL_SPI_Transmit(). It was late yesterday.
Today i am going to debug it correctly and i will post the results here.
My clock frequenz is max 72MHz and i looked at block diagram of blue pill and saw that SPI2 is on APB1 which has max 36MHz, so shall i change the cinfiguration in any way different than SPI1?


@hamo wrote:

 i looked at block diagram of blue pill and saw that SPI2 is on APB1 


"Blue Pill" is just a board; it doesn't affect the internals of the chip - that remains the same irrespective of what board it's mounted on!

You need to be looking at the chip documentation - Datasheet and Reference Manual.

https://www.st.com/en/microcontrollers-microprocessors/stm32f103c8.html#documentation 

But, yes - getting the clock configurations correct is essential to everything!

You say you're using STM32CubeMX - the 'Clock Configuration' tab there will flag any clock setting issues ...

hamo
Senior

Hello,

i have debugged it and found out that when goes into hal_spi_transmit() it initilaize every thing correct and when it try to transmit the data it chosses to transmit data in 8 bit mode (which is correct) it waits till TXE flag is set to send data, but goes to time out which means that TXE flag is not set (i think).

It keeps stuck there. I have tried to change RESET, CS and DC pins but without success.SPI2_debugging_1.JPG

Read out and check/post content of SPI and relevant GPIO/AFIO registers.

Observe SPI pins. Do you see SCK toggling?

JW