Aliexpress OLED 16x02 not working/WS0012

Wow, I'm really pulling my hair out on this. So far none of the recommended initialization procedures in the datasheet truly work. Yes it works from a power cycle but they are not reliable from a warmstart once the device is already operating in 4 bit mode.
That and I can't fully figure out what is going with the Clear Display and Return Home instructions. They just don't work correctly and the Home doesn't always work the same way.

Definitely not impressed with the IST0010 chipset.

--- bill

This !@#$!#$#!@$ forum software!!!!!!!!!!!!!!!!!!!!!!!!
You can't post more than 3 posts without someone doing a replay.
There is no reason to do this type of nonsense.


Here is my next update:
So the weirdness continues.
I'm currently testing on an UNO platform. (16Mhz AVR)
There is some sort of Arduino Core library or compiler issue that is causing problems.
I need to do some disassembly to see what is happening but here is the issue:

Background:
The IST code library seems to be able to reliably initialize the display.
It uses a different set of instructions than what the data sheet recommends.
I changed the IST library code to use a delay rather than poll busy to get it closer to the hd44780 library code.

Now for the REALLY strange part:

If delayMicroseconds() is the last thing in a function before a return,
then the initialization fails. If I insert some dummy code after delayMicroseconds() then it works.
If I switch to using delay() it works but the timing is slower than needed.

Even stranger, if I do this:

delayMicroseconds(50);
delay(1);

It works.
However, If I do this:

delay(1);
delayMicroseconds(50);

It fails.

I'm guessing that there is some kind of issue with the inline assembler in the delayMicroseconds() function that breaks the optimizer and somehow no delays are done including the delay() call.

This will take looking at the assembler to see what is happening.
Pretty crazy.

--- bill