1
\$\begingroup\$

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:

enter image description here

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):

enter image description here

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.

\$\endgroup\$
6
  • \$\begingroup\$ Here are the links of the datasheets: DD-32645C-2A and the connector board \$\endgroup\$
    – koalag
    Commented Jun 21, 2016 at 9:19
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – MarkU
    Commented Jun 21, 2016 at 10:07
  • \$\begingroup\$ Your code doesn't write any data to the display (there are no calls to write_d). \$\endgroup\$
    – user57709
    Commented Jun 21, 2016 at 10:08
  • \$\begingroup\$ @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. \$\endgroup\$
    – koalag
    Commented Jun 21, 2016 at 10:31
  • \$\begingroup\$ @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. \$\endgroup\$
    – koalag
    Commented Jun 21, 2016 at 10:34

1 Answer 1

1
\$\begingroup\$

This behavior is normal. The initialization sequence that you're sending doesn't clear the display; it just gets the display ready to display data. Since the display hasn't been cleared, it will display whatever random data happens to be in memory at startup.

To clear the display, set an address and start writing some data to it.

\$\endgroup\$
1
  • \$\begingroup\$ Took me some time to get back to this project, but you were right all along. \$\endgroup\$
    – koalag
    Commented Aug 20, 2016 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.