OLED Display turning off 1 sec after upload

Hello,

I am currently trying to get a US Micro Products OLED Display P21301 ( Attached is the SPI application datasheet). The problem that I am running into is that about 1 second after I upload the code below any text that is on the screen goes away. If I hit the reset button on the Arduino Mega 2560 the text will come back up and stay as long as I hold the reset button down. Once I release the button the text goes away as before. Strangely twice during testing yesterday the display worked completely fine and I was able to send different text to the display using the serial monitor. That code isn’t shown but the problem occurs even with the “testing SSD1322” text.

Some things about the set up. I’ve checked the capacitors and they look to be correct as what is shown by the datasheet. Also, I have contacted the company to about the problem to see if there is anything they know (no response yet). I am using a SN74LVC245A to shift the I/O from the arduino from 5V to 3.3V max. We have all SPI connections running through the level shifter ( MOSI, SCK, CS, AO, and RESET). I’m not sure if this affects the timing enough to turn off the display.

Let me know if there is anything else that would be beneficial. The breadboard is a little messy but I can take pictures or provide any other information if needed. Thanks so much for your help.

#include "U8glib.h"



const uint8_t mosi = 51; //good
const uint8_t sck = 52; //good
const uint8_t cs = 53; //good
const uint8_t miso = 50; //Don't wire
const uint8_t reset = 48;
const uint8_t a0 = 49;

U8GLIB_NHD31OLED_GR u8g(52, 51, 53, 49, 48);



//#define HomeScreenDataFont u8g_font_helvB10

//#define HomeScreenDataFont u8g_font_helvB10

//#define HomeScreenDataFont u8g_font_ncenB18 //18 pixel, too big for design #1

#define HomeScreenDataFont u8g_font_gdr17 //17 data font option

#define LabelFontBOLD u8g_font_7x13B //label font bold

#define LabelFont u8g_font_6x12 // 7 pixel font

#define DataFont u8g_font_ncenB18 //bold font

#define NumericDataFont u8g_font_ncenB18 //bold font


#define FluidDataFont14size u8g_font_fub14	//14 pixel height

#define pixelTenFont u8g_font_9x15B 

//copy and paste from display
const uint8_t LabelTextMaxSize = 40;

/**
@brief Stores X & Y pixel position for a Point
*/
struct Point
{
	uint8_t	x;
	uint8_t y;
};

/**
@brief Line comprised of two points
*/
struct Line
{
	Point p1;
	Point p2;
};

struct Label
{
	Point pos;
	uint8_t width;
	const u8g_fntpgm_uint8_t *font;
	char title[LabelTextMaxSize];
};


struct DataLabel
{
	Point pos;
	uint8_t precision;
	const u8g_fntpgm_uint8_t *font;
	float data;
};


struct BitMap
{
	Point StartingPoint;
	uint8_t Width;
	uint8_t Height;
	//No pointer to BitMap object to avoid using malloc...
	//todo: Use classes instead of structs?
};


const static unsigned char DropIconImage[] U8G_PROGMEM ={
	0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xc0, 0x03, 0xc0, 0x03,
	0xe0, 0x07, 0xe0, 0x07, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f,
0xe0, 0x07, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00 };

BitMap DropIcon = {{25,0}, 16 , 16};


const static unsigned char TempIconImage[] U8G_PROGMEM = {
	0x00, 0x00, 0xe0, 0x01, 0x20, 0x06, 0x20, 0x02, 0x20, 0x06, 0x20, 0x02,
	0xa0, 0x06, 0xa0, 0x02, 0xa0, 0x02, 0x90, 0x04, 0xd0, 0x05, 0xd0, 0x05,
0xd0, 0x05, 0x10, 0x04, 0xe0, 0x03, 0x00, 0x00 };

BitMap TempIcon = {{88,0}, 16 , 16};

void draw(void) {
	// graphic commands to redraw the complete screen should be placed here
	u8g.setFont(u8g_font_unifont);
	u8g.drawStr( 0, 22, "Testing SSD1322");
	//	u8g.
	//u8g.print("Hello");
}

void setup(void) {
	Serial.begin(9600);
	Serial.println(F("Testing ssd1322"));
	// flip screen, if required
	// u8g.setRot180();
	
	// SET SPI backup if required
	//u8g.setHardwareBackup(u8g_backup_avr_spi);

	// assign default color value
	if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
		Serial.println("white");
		u8g.setColorIndex(255);     // white
	}
	else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
		Serial.println("max");
		u8g.setColorIndex(3);         // max intensity
	}
	else if ( u8g.getMode() == U8G_MODE_BW ) {
		Serial.println("pixel");
		u8g.setColorIndex(1);         // pixel on
	}
	else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
		Serial.println("High color");
		u8g.setHiColorByRGB(255,255,255);
	}
	
	splash();
}

void splash()
{
	// picture loop
	u8g.firstPage();
	do {
		draw();
	} while( u8g.nextPage() );
}

void loop(void) {

	
	// rebuild the picture after some delay
	delay(500);
	Serial.print(".");
	
	WaitForSerialCommands();
}

void WaitForSerialCommands()
{
	int incomingByte = 0;
	
	while (!Serial.available());
	
	while (Serial.available())
	{
		incomingByte = Serial.read();
	}
	} 
}

P21301 SPI Application Notes A01.pdf (510 KB)

How is the OLED powered?
Will it work with an external power supply for the OLED?

Oliver

I actually just solved the problem. According to the datasheet the VDDIO had to be less than VCI. My VCI was about 3.2V and VDDIO was getting around 2.9V. I switched up the voltage divider to give about 1.9V and it worked. It was a good lesson learned: keep the VDDIO much lower than the VCI.