Two ssd1306 Init problem (closed)

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 60 times
Contact:

Two ssd1306 Init problem (closed)

Post by viktor_au »

Gear:
Arduino Nano,
ssd1306-1: address 0x78, not interlaced, 100KHz
ssd1306-2: address 0x7a, not interlaced, 100KHz
Note: both displays connected and work OK with Nano if Init is done only for one of them.

What is done:
FC8 is updated

What is checked:
Two ssd1306 oled's have been added to dashboard panel - OK
--------------------------------------------------------------------
ssd1306-1 (0x78) ->Init->print text - OK
ssd1306-2 (0x7a) ->Init function is added-> system is crashed.
--------------------------------------------------------------------
ssd1306-1: (address is changed to 0x7a) ->Init->print text - OK
Note: ssd1306-2 is not initialised
--------------------------------------------------------------------
ssd1306-1: (address is 0x7a) ->Init->print text - OK
ssd1306-2 is initialised: system is crashed.
--------------------------------------------------------------------

Result
Each ssd1306 initialised OK at address 0x78 or at address 0x7a and work OK if:
Second ssd1306 is not initialised.
When both ssd1306 have been initialised, the system is crashed.
Attachments
NanoTwoSsd1306Init.fcfx
(16.52 KiB) Downloaded 181 times
Last edited by viktor_au on Fri Nov 09, 2018 10:03 pm, edited 1 time in total.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Two ssd1306 Init problem

Post by Benj »

Hello,

Please can I try a quick test to see if we can make this work for you.

If you insert a C icon after initialising the first display but before you initialise the second and enter the following code to reset the I2C registers back to default.

Code: Select all

TWCR = 0;
TWSR = 0xF8;
TWDR = 0xFF;
Let us know how you get on.

If this works then would you mind commenting out a line or two at a time and seeing specifically which register reset is responsible for the solution. My money would be on this line.

Code: Select all

TWCR = 0;

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 60 times
Contact:

Re: Two ssd1306 Init problem

Post by viktor_au »

No Benj.
It does not work.
-------------------

Is it possible to use the multiplexer?

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 60 times
Contact:

Re: Two ssd1306 Init problem

Post by viktor_au »

ssd1306 Initialisation macro sends each byte by using the SendCommand macro with the device address (used by Master_TxByte).
In case of using two Init macros for two ssd1306 devices with addresses as 0x78 and 0x7a the program tries to re-write the parameters like: display on/off, set charge pump, re-map, contrast and so on...
Is it the reason why both screens are off?
I tried not to write text or numbers, but to print one pixel on screen.
If the 1st device initialised with the address as 0x7a, the pixel is printed. But the second device with address 0x78 shows nothing.
Can you give me the direction Benj?

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 60 times
Contact:

Re: Two ssd1306 Init problem

Post by viktor_au »

I have managed to print the numbers on both displays. But the program is not stable and constantly goes into reset.
The Arduino boards with Atmega328 chip (Uno, Nano...) have 2K of SRAM.
Monochrome OLED Displays (128x64 version) requires 1K of SRAM. 128x64 is 8192 pixels. Or 1024 bytes.
When the program writes the 1st display data into SRAM it works fine but not when the second display data
messed up the stack and once the return address on the stack points to 0 - the next return statement will create the reset.

Post Reply