Skip to content

Second SPI not working for ST7920 using with STM32F103C8T6 (Blue Pill) or STM32F401CCU (Black Pill) #1208

@delgadosouza

Description

@delgadosouza

Dear @olikraus , thank you for this great library!

I have a Blue Pill STM32F103C8T6 and also a Black Pill STM32F401CCU and I would like to use a ST7920 display on the SPI2 (pins PB12 to PB15). Any of the microcontrollers would be great. The screen only works reliably with low frequencies (<2MHz) so the second SPI is perfect. On the SPI1 I have another sensor.

I used the SW constructor on those pins (PB12 to PB15) and it works fine but slow. Unfortunately, because my project is interactive I can't use it with this speed. While with Hardware SPI I got a 55ms refresh rate, with Software SPI I got only 250ms on the BluePill and 150ms with the BlackPill.

I am using the official Arduino_Core_STM32 by stm32duino. My entire project is based on this core so changing for another core would require changing and testing everything again...

I tried the HW version:

U8G2_ST7920_128X64_F_2ND_HW_SPI disp(LCDROTATION, SS_RS_CS, RST_RESET);

and it compiles but nothing is shown on the screen.

So I tried defining SPI_INTERFACES_COUNT 2 on the beggining of the U8x8lib.h file and got the error:

\src\U8x8lib.cpp:1000:7: error: request for member 'transfer' in '(SPI_TypeDef*)((1073741824 + 65536) + 12288)', which is of pointer type 'SPI_TypeDef*' (maybe you meant to use '->' ?)

So I openned the U8x8lib.cpp file and tried to hardcode the constructor for the second SPI. By the documentation in their wiki the constructor for the second SPI would be:

SPIClass mySPI_2(uint8_t mosi, uint8_t miso, uint8_t sclk, uint8_t ssel)

Then I switched all occurrences of SPI1 to mySPI_2 and it compiled but the screen was blank.

I have sill a lot to learn so I have no ideas on how to solve this... Is it really a problem with the core I am using that don't follow the Arduino API? They claim that they follow the API and that Roger's core doesn't.

I tried using the nightly build of Arduino IDE and also the beta release (Arduino 1.9).

If the problem really is with the core, do you have any suggestions for a workaround?

Any help would be really apreciated!
Thank you again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions