-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Second SPI not working for ST7920 using with STM32F103C8T6 (Blue Pill) or STM32F401CCU (Black Pill) #1208
Comments
Hi! @delgadosouza @olikraus I have the same issue! I can't use HW constructor for ST7920 |
Hi @marekche, I believe Arduino Mega have only one SPI that is probably what you are trying to use.
About the SPI2 I asked the people on the Arduino_Core_STM32 and they say that the SPI implementations is fine... |
Oh, you must set the correct pins, of course. |
Thanks @delgadosouza I tried, but without successful :( Always nothing in the screen. |
It sure is! For me it takes around 55ms to refresh the entire screen on hardware SPI. With software SPI it goes to 250ms but that is using STM32F103 which is faster than Arduino Mega. I believe 40ms for a pixel is too much, even for software SPI. How many pixels are on the screen? |
Maybe I can help, can you give me more of your code? |
Yes, sure! This is a part of the code! Thanks a lot again... ` #include <Arduino.h>
}` |
Regarding the time, it will take a minimum time to refresh the screen. So even printing nothing on the screen it may take the 35ms you are measuring just to send the command to the screen. |
No, not increase lenearly! If a draw the axis for example, it take 40-45ms around. |
The approach looks ok to me... I believe that the time to send the data to the screen is fixed and only depends on the communication (HW SPI, SW SPI, frequency clock, etc). The remaining of the time is the time for the code to run the computations and fill the buffer to be sent to the screen. |
Thanks a lot @delgadosouza It was my mistake about the connection with arduino! |
Its take around 48-50ms every refresh! I need findout other way to do the graph in realtime! Thank you again for your time! |
Essentially a display update in u8g2 has two components. If not using the 'F'-constructors u8g2 divides the screen into N pages. If you know in what page you are and draw only in that page you can speed up drawing (user clipping). (f.e. Don't try draw icons not at the current page) If you have time critical tasks, like when a buffer is running over when it is not polled often enough if done outside the picture loop - pull that into the loop - the polling interval will than be ~ 1/N. Just be sure the polling will not alter the displays content. |
Interesting... so if I don't use the F constructor I can monitor a sensor more frequently without afecting the refresh rate for the entire screen? I will try that! @AnHardt do you have any suggestions about my problem with hardware SPI2 on STM32F103 or STM32F401? |
@AnHardt Thanks a lot for your explanation! It was very helpful. |
Hi All I can not say much regarding the STM32 implementation. If the second SPI is implemented in the same way as for standard Arduino libs, then it should work. If not then it is probably difficult, because I do not want to create an exception for each and every other lib. HW SPI in Arduino Mega should work. If not, then often there are wiring issues because the HW SPI pins are fixed on Arduino Mega |
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 theU8x8lib.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
tomySPI_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.
The text was updated successfully, but these errors were encountered: