0
\$\begingroup\$

It's my first project this big - an arduino (Pro Micro) based midi controller. After all the research, schematics and pcb designing I got to assembly and wanted to try out the display, but then I can't get it to work!

Example code, from recommended u8g2 lib is:

#include <Arduino.h>
#include <SPI.h>
#include <U8g2lib.h>
const byte clock = 15;
const byte data = 14;
const byte cs = 9;
const byte reset = 8;

U8G2_SH1106_128X64_NONAME_F_3W_SW_SPI u8g2(U8G2_R0, clock, data, cs , reset);

void setup(void) {
  SPI.begin();
  u8g2.begin();
}

void loop(void) {
  u8g2.firstPage();
  do {
    u8g2.setFont(u8g2_font_ncenB14_tr);
    u8g2.drawStr(0,15,"Hello World!");
  } while ( u8g2.nextPage() );
  delay(1000);
}

Tried all the listed constructors, SW HW, all the models and buffer sizes. I run the connections to the display through TXS0104EDR logic converter (SMD, so prototyping off-pcb seems not doable, but maybe I should try?)

Maybe from all the components power draw, 5V actually measures 4.65V. Voltage divider (5k,10k) when connected to the load measured ~0.8V, so I swapped it for a 5k potentiometer to set the voltage manually to 3.3V

enter image description here

I can't figure out what I'm doing wrong.


So I just swapped the voltage divider for a LD33CV regulator, still nothing.

I'm Starting to wonder if it's not a model suited only for 4pin communication. In the documentation, some manipulation is needed to work in 3pin mode: IM0 pulled up, DC pulled down, but here's my chip, no IM0 connection: enter image description here

Where do you think I should go from here? My ideas:

  • Wire a 5v logic signal from let's say A2 to D/C input
  • Swap 3.3V CS for D/C, pull CS always low (then somehow omit soft pin requirement)
  • Get a different screen capable of 3pin?

Update: I risked one chip, wired all in 5V logic and it worked! :) My first idea, with 5v D/C signal also worked on the pcb. However tivial, this feels like a win :) It's my first time posting here, so thank you all for support

But some question remains: Why is it working only in Software-emulated SPI mode? when i change the constructor to hardware(no clock and data pins specified), no more. It seems very time-inefficient. loop like this:

t = millis() - last;
  last = millis();
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_ncenB14_tr);
  u8g2.setCursor(0,20);
  u8g2.print(t,10);
  u8g2.sendBuffer();

displays around 15 ms.

\$\endgroup\$
12
  • 4
    \$\begingroup\$ You're trying to use a voltage-divider as a power supply. That's not going to work. electronics.stackexchange.com/questions/106718/… \$\endgroup\$
    – brhans
    Commented Dec 14, 2023 at 11:32
  • \$\begingroup\$ Hah, I thought since oled use little current I could get away with it :) So a 3.3V linear regulator would be a proper solution? \$\endgroup\$
    – jasioloza
    Commented Dec 14, 2023 at 11:54
  • 2
    \$\begingroup\$ It's not the current used that matters, it's the variability of the current. You could get away with a resistor and a zener for a low-tolerance application, but not a two-resistor divider. \$\endgroup\$
    – Hearth
    Commented Dec 14, 2023 at 15:40
  • \$\begingroup\$ I would have blamed the TXS0104. Most often people ask why their system does not work, and they have a similar level shifter there and used incorrectly. By incorrectly I mean things that are not visible in schematics. \$\endgroup\$
    – Justme
    Commented Dec 14, 2023 at 18:56
  • \$\begingroup\$ @Justme when I skipped the TXS, ran on 5v logic, hardware SPI still didn't work. \$\endgroup\$
    – jasioloza
    Commented Dec 14, 2023 at 19:34

1 Answer 1

0
\$\begingroup\$

Two reasons why the hardware SPI does not work for you.

Arduino pin 16 is the hardware SPI MOSI data output, but in your schematic you use Arduino pin 14 which is the hardware SPI MISO data input.

In addition, the SPI hardware SS pin is used for onboard LED. That's fine as any pin can be used for SS in software, but the hardware SS pin must still be set as output. If the hardware SPI SS pin is left as an input, expect problems, as the hardware SPI will drop from master to slave mode when SS is input and it goes low. And it can't even be used as input with internal pull-up, because the LED will load it down to logic low.

\$\endgroup\$
2
  • \$\begingroup\$ Oh my, I did really mistake MISO for MOSI. I'll update when I see what happens with rewiring these two between Arduino and the PCB. Could you elaborate on the RX_led problem? If it's controlling a led, it's not set as output? Pro micro doesn't have an outboard SS connection and the oled libary seem to be using software Chip Select pin, provided in a hardware constructor. \$\endgroup\$
    – jasioloza
    Commented Dec 16, 2023 at 11:55
  • \$\begingroup\$ @jasioloza The hardware SS must be an output, no matter for what you use it, or if you don't even use it for anything. \$\endgroup\$
    – Justme
    Commented Dec 16, 2023 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.