Guest
#3568257
Here is the code I am using to initialize the OLED, per the instructions in the data sheet. I am using the 3-wire SPI configuration, and I have set BS0 and BS1 correctly. For reference, here is the exact OLED I bought: http://www.buydisplay.com/default/graphic-oled-display-module-3-2-inch.html And here is my code: void Initial(void) { PINRESETHIGH; timer_delay(5); /* in miliseconds */ PINRESETLOW; timer_delay(20); PINRESETHIGH; timer_delay(5); Write_Command(0xA6); /* All off or normal, Data sheet is inconsitent */ Write_Command(0xFD); /*SET COMMAND LOCK*/ Write_Data(0x12); /* UNLOCK */ Write_Command(0xAE); /*DISPLAY OFF*/ Write_Command(0xB3); /*DISPLAYDIVIDE CLOCKRADIO/OSCILLATAR FREQUANCY*/ Write_Data(0x91); Write_Command(0xCA); /*multiplex ratio*/ Write_Data(0x3F); /*duty = 1/64*/ Write_Command(0xA2); /*set offset*/ Write_Data(0x00); Write_Command(0xA1); /*start line*/ Write_Data(0x00); Write_Command(0xA0); /*set remap*/ Write_Data(0x14); Write_Data(0x11); Write_Command(0xB5); /* Set GPIO */ Write_Command(0x00); Write_Command(0xAB); /* Funtion selection */ Write_Data(0x01); /* Selection external vdd */ Write_Command(0xB4); /* Enable External VSL */ Write_Data(0xA0); Write_Data(0xFD); Write_Command(0xC1); /* Set contrast current */ Write_Data(Contrast_level); Write_Command(0xC7); /* Master contrast current control*/ Write_Data(0x0F); Write_Command(0xB9); /* Select default linear grey scale table */ Write_Command(0xB1); /* SET PHASE LENGTH */ Write_Data(0xE2); Write_Command(0xD1); /*Enhance driving scheme capability*/ Write_Data(0x82); Write_Data(0x20); Write_Command(0xBB); /*SET PRE-CHANGE VOLTAGE*/ Write_Data(0x1F); Write_Command(0xB6); /*SET SECOND PRE-CHARGE PERIOD*/ Write_Data(0x08); Write_Command(0xBE); /* SET VCOMH */ Write_Data(0x07); Write_Command(0xA4); /* normal display or all off, not sure which */ Clear_Ram(); timer_delay(200); Write_Command(0xAF); /*display ON*/ return; } void Write_Command(unsigned char cmd) { uint16_t new_cmd = 0x0000; /* 9th bit = 0 for sending command */ new_cmd |= cmd; sendMessageSPI2(new_cmd); return; } void Write_Data(unsigned char dat) { uint16_t new_data = 0x0100; /* 9th bit = 1 for sending data */ new_data |= dat; sendMessageSPI2(new_data); return; } void main(void) { BOARD_Init(); /* Init code for my personal board */ INITPIN29; /* Initialize the reset pin */ Gui_Init(); /* Initializes SPI, Timers, and empty arrays */ Write_Command(0xA6); //--all Display off Initial(); while (1) { printf("ON!\n"); Write_Command(0xA5); //--all display on timer_delay(5000); printf("OFF!\n"); Write_Command(0xA6); //--all Display off timer_delay(5000); } } NOTE: The OLED will not even turn on, not once. No screen flicker, nothing. I have triple checked everything on the hardware side over and over again, so I am convinced that it is software. Any help would be appreciated. Thanks!