# Faulty display behavior using a Atmega328 due to (wrong?) logic voltage level

I have built a little circuit using a Atmega328P to drive a DD-32645C-2A display using a connector board. The display uses a SSD1303 driver.

So here is my circuit:

Pretty straight forward, I think. I use the C port to set the control pins of the display and the D port to send commands/data. Here is the code I programmed onto my MCU:

#include <avr/io.h>
#define F_CPU 8000000UL
#include <util/delay.h>

void inital(void);
void write_c(unsigned char ins_c);
void write_d(unsigned char ins_d);

int main(void)
{
// set ports D and C as output
DDRC = 0b11111111;
DDRD = 0b11111111;

inital();

while (1)
{
}
}

void inital(void)
{
PORTC &= 0b00000000;    // reset display pins
_delay_ms(150);         // delay 150ms for reset
PORTC |= (1 << 5);      // set RES to high

write_c(0xAE);
write_c(0x81);
write_c(0xAF);
write_c(0xA8);
write_c(0x3F);
write_c(0xA0);
write_c(0xD3);
write_c(0x00);
write_c(0x40);
write_c(0xC8);
write_c(0xDA);
write_c(0x12);
write_c(0xD9);
write_c(0xF1);
write_c(0xDB);
write_c(0x49);
write_c(0xA4);
write_c(0xA6);
write_c(0xAF);
}

void write_c(unsigned char ins_c)
{
PORTC = 0b00010100;     // set pins for sending commands
PORTD = ins_c;
PORTC = 0b00011111;
}

void write_d(unsigned char ins_d)
{
PORTC = 0b00010101;     // set pins for sending data
PORTD = ins_d;
PORTC = 0b00011111;
}


Also not to complicated, I think. I set up my C and D ports as outputs and call my initialization function. This function resets the display and sends a series of command to set it up(I simply copied this routine from the display's datasheet). The other two functions simply send a byte of data using port D.

Now here's my problem: The setup routine seems to work fine, but my display looks like this(I apologize for my bad camera):

The first picture shows what I got initially, which is not really convincing. Now, after double and triple checking all of my connections and code for errors, I accidentally forgot to reconnect the VDD power(3.3V) to the connector board, which drives the display driver's logic(see page 5 of the connector board datasheet in the comment). And that result is shown on the second/lower picture above.

Still not perfect, but much closer to the desired effect. There should be on big blue rectangle and four smaller colored ones at the top. But still some pixels won't light up.

Has anyone a idea what is going on here? Not connecting the VDD pin for the display driver's logic doesn't make any sense to me, but makes my display work better.

• Here are the links of the datasheets: DD-32645C-2A and the connector board Jun 21 '16 at 9:19
• Is that really the schematic? C1 should be connected between VCC and GND. The way the schematic is drawn, there is no DC connection to ground, the GND pins connect to ground return only through C1. This won't work reliably, I'm surprised it works at all... Try connecting pins 8 and 22 directly to ground return, and adding another ceramic 1uF capacitor between VCC and GND close to the ATmega328P. Jun 21 '16 at 10:07
• Your code doesn't write any data to the display (there are no calls to write_d). Jun 21 '16 at 10:08
• @MarkU: Don't worry, I just drew that really fast to show the concept. Of course there is a capacitor right between pins 7 and 8, and 20 and 22 respectively. Jun 21 '16 at 10:31
• @user57709: That is correct, but running the standard setup routine, should display the rectangles I described, check page 13 of the display's datasheet for details. Jun 21 '16 at 10:34