-
Notifications
You must be signed in to change notification settings - Fork 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
Using u8g2 and SPI #794
Comments
The latest ST7920 datasheet page 26 second paragraph, tells us CE is broken, don't use it with together with other devices on the bus. Mostly only a garbed display is observed, but depending on what is send to the other devices worse thing can happen. Safest is to ether use a separate spi-bus for the ST7920 or use some AND-gates to keep SCLK and SI quite when CE is not selected. |
What do you mean by "CE is broken"? And BTW, here is a piece of code to illustrate: #include <Arduino.h>
#include <U8g2lib.h>
#include <SPI.h>
U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 52, /* data=*/ 51, /* CS=*/ 30, /* reset=*/ U8X8_PIN_NONE);
const int potsCSPins[] = {41, 40, 43, 42, 45, 44, 46, 47};
void setup(void) {
Serial.begin(9600);
SPI.begin();
for(int i=0; i<8; i++) {
pinMode(potsCSPins[i], OUTPUT);
digitalWrite(potsCSPins[i], HIGH);
Serial.print("Setting pot " + String(i) + " to 128");
setPot(potsCSPins[i], 128);
Serial.println(" Done!");
}
u8g2.begin();
}
void loop(void) {
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font
u8g2.drawStr(0,10,"Hello World!"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
void setPot(uint8_t cspin, uint8_t value) {
digitalWrite(cspin, LOW);
SPI.transfer(B00010001);
SPI.transfer(value);
digitalWrite(cspin, HIGH);
} |
The datasheet describes a, compared to other SPI devices, very different (broken) behavior of the controllers CE pin. In former versions of the datasheet a normal behavior was described. (Errata) |
And there is no way to patch this behavior in the code? |
Maybe - the day we can fix a flat tire with a firmware update. |
See #767, exactly the same issue. |
Hardware reset, reinitialize, reprint could work. Never tried. Up to now reprint was enough. |
Found the solution in #767. Using HW SPI in beta 2.25.2 solves the issue. The constructor: U8G2_ST7920_128X64_F_HW_SPI u8g2(U8G2_R0, 30, U8X8_PIN_NONE); |
I like "self-solving" issues. :-) |
Hi.
I'm using a ST7920 SPI display, coupled with 8 MCP41010 SPI potentiometers.
When I use u8g2 do draw on my display only, everything's fine.
When I set my potentiometers using SPI, it's ok too.
But when I try to do both, u8g2 can't draw anymore.
Is there a way to place an ST7920 and the MCP41010 on the same SPI line and make them work altogether using u8g2 (for the display) and regular SPI functions for the MCPs?
Thanks a lot for your help.
The text was updated successfully, but these errors were encountered: