Depuración de la inicialización de la pantalla LCD con el controlador S6D05A1

0

Estoy intentando que este LCD de 320 x 480 pase por SPI (4 hilos 8 bits) por un tiempo, pero no tengo suerte. Parece que la resolución no está definida como debería durante el inicio pero no puedo ver cómo.

Aquí, lo que veo después de ejecutar el código que debe pintar todo el LCD de azul:

Aquí está la función de prueba:

LCDWriteCommand(0x2A);
LCDWriteData(0x00);
LCDWriteData(0x00);
LCDWriteData(0x01);
LCDWriteData(0x3F);
LCDWriteCommand(0x2B);
LCDWriteData(0x00);
LCDWriteData(0x00);
LCDWriteData(0x01);
LCDWriteData(0xDF);
LCDWriteCommand(0x2C);

for(uint16_t i = 0; i < 320; i++) // Y
{
    for(uint16_t j = 0; j < 480; j++)
    {
        LCDWriteData(BLUE>>8);
        LCDWriteData((uint8_t)BLUE);
    }
}

Las direcciones de la memoria son de 0 a 319 y amp; 0 a 479, por lo que debería estar bien para esta pantalla LCD por lo que puedo ver.

Aquí está el propio código de inicio:

    LCDWriteCommand(0xF0); // PASSWD1 - OK
    LCDWriteData(0x5A);
    LCDWriteData(0x5A);

    LCDWriteCommand(0xF1); // PASSWD2 - OK
    LCDWriteData(0x5A);
    LCDWriteData(0x5A);

    LCDWriteCommand(0xF2); // DISCTL (Display Control)
    LCDWriteData(0x3B);    // 480 scan lines
    LCDWriteData(0x33);
    LCDWriteData(0x03);
    LCDWriteData(0x0C);
    LCDWriteData(0x08);
    LCDWriteData(0x08);
    LCDWriteData(0x08);
    LCDWriteData(0x00);
    LCDWriteData(0x08);
    LCDWriteData(0x08);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x33);
    LCDWriteData(0x0C);
    LCDWriteData(0x08);
    LCDWriteData(0x0C);
    LCDWriteData(0x08);

    LCDWriteCommand(0xF4);
    LCDWriteData(0x07);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x04);
    LCDWriteData(0x70);
    LCDWriteData(0x03);
    LCDWriteData(0x04);
    LCDWriteData(0x70);
    LCDWriteData(0x03);

    LCDWriteCommand(0xF5);
    LCDWriteData(0x00);
    LCDWriteData(0x46);//Set VCOMH
    LCDWriteData(0x70);//Set VCOM Amplitude
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x02);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x46);
    LCDWriteData(0x70);

    LCDWriteCommand(0xF6);
    LCDWriteData(0x03);
    LCDWriteData(0x00);
    LCDWriteData(0x08);
    LCDWriteData(0x03);
    LCDWriteData(0x03);
    LCDWriteData(0x00);
    LCDWriteData(0x03);
    LCDWriteData(0x00);

    LCDWriteCommand(0xF7);
    LCDWriteData(0x48);
    LCDWriteData(0x80);//RGB_MCU(DM)
    LCDWriteData(0x10);
    LCDWriteData(0x02);
    LCDWriteData(0x00);

    LCDWriteCommand(0xF8);
    LCDWriteData(0x11);
    LCDWriteData(0x00);

    LCDWriteCommand(0xF9); //Gamma Selection
    LCDWriteData(0x14);

    LCDWriteCommand(0xFA); //Positive Gamma Control
    LCDWriteData(0x33);
    LCDWriteData(0x07);
    LCDWriteData(0x04);
    LCDWriteData(0x1A);
    LCDWriteData(0x18);
    LCDWriteData(0x1C);
    LCDWriteData(0x24);
    LCDWriteData(0x1D);
    LCDWriteData(0x26);
    LCDWriteData(0x28);
    LCDWriteData(0x2F);
    LCDWriteData(0x2E);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);

    LCDWriteCommand(0xFB); //Positive Gamma Control
    LCDWriteData(0x33);
    LCDWriteData(0x03);
    LCDWriteData(0x00);
    LCDWriteData(0x2E);
    LCDWriteData(0x2F);
    LCDWriteData(0x28);
    LCDWriteData(0x26);
    LCDWriteData(0x1D);
    LCDWriteData(0x24);
    LCDWriteData(0x1C);
    LCDWriteData(0x18);
    LCDWriteData(0x1A);
    LCDWriteData(0x04);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);

    LCDWriteCommand(0xF9); //Gamma Selection
    LCDWriteData(0x12);

    LCDWriteCommand(0xFA); //Positive Gamma Control
    LCDWriteData(0x36);
    LCDWriteData(0x07);
    LCDWriteData(0x04);
    LCDWriteData(0x1C);
    LCDWriteData(0x1C);
    LCDWriteData(0x23);
    LCDWriteData(0x28);
    LCDWriteData(0x1C);
    LCDWriteData(0x25);
    LCDWriteData(0x26);
    LCDWriteData(0x2E);
    LCDWriteData(0x2B);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);

    LCDWriteCommand(0xFB); //Positive Gamma Control
    LCDWriteData(0x33);
    LCDWriteData(0x06);
    LCDWriteData(0x00);
    LCDWriteData(0x2B);
    LCDWriteData(0x2E);
    LCDWriteData(0x26);
    LCDWriteData(0x25);
    LCDWriteData(0x1C);
    LCDWriteData(0x28);
    LCDWriteData(0x23);
    LCDWriteData(0x1C);
    LCDWriteData(0x1C);
    LCDWriteData(0x04);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);

    LCDWriteCommand(0xF9); //Gamma Selection
    LCDWriteData(0x11);

    LCDWriteCommand(0xFA); //Positive Gamma Control
    LCDWriteData(0x33);
    LCDWriteData(0x07);
    LCDWriteData(0x04);
    LCDWriteData(0x30);
    LCDWriteData(0x32);
    LCDWriteData(0x34);
    LCDWriteData(0x35);
    LCDWriteData(0x11);
    LCDWriteData(0x1D);
    LCDWriteData(0x20);
    LCDWriteData(0x28);
    LCDWriteData(0x20);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);

    LCDWriteCommand(0xFB); //Positive Gamma Control
    LCDWriteData(0x33);
    LCDWriteData(0x03);
    LCDWriteData(0x00);
    LCDWriteData(0x20);
    LCDWriteData(0x28);
    LCDWriteData(0x20);
    LCDWriteData(0x1D);
    LCDWriteData(0x11);
    LCDWriteData(0x35);
    LCDWriteData(0x34);
    LCDWriteData(0x32);
    LCDWriteData(0x30);
    LCDWriteData(0x04);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x00);

    LCDWriteCommand(0x44);
    LCDWriteData(0x00);
    LCDWriteData(0x01);

    LCDWriteCommand(0x2A);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x01);
    LCDWriteData(0x3F);

    LCDWriteCommand(0x2B);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x01);
    LCDWriteData(0xDF);

    LCDWriteCommand(0x36); //Memory Data Access Control
    LCDWriteData(0x00);

    LCDWriteCommand(0x3A); //SET 65K Color
    LCDWriteData(0x55);

    LCDWriteCommand(0x11);
    _delay_ms(120);

    LCDWriteCommand(0x29);//Display on
    LCDWriteCommand(0x2C);//Write GRAM

    _delay_ms(10);
    LCDWriteCommand(0x36); //Set_address_mode
    LCDWriteData(0x60); //???????????????????

Sé que esto es muy largo, sin embargo, tal vez alguien tenga algo de experiencia y pueda ayudar rápidamente. Gracias!

    
pregunta user34920

1 respuesta

0

Las direcciones finales de la memoria LCD deben intercambiarse (segundo parámetro de los comandos 0x2A y 0x2B). Una función de prueba de trabajo que dibuja líneas de colores en la pantalla se ve así:

void LCDTestColor()
{
    LCDWriteCommand(0x2A);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x01);
    LCDWriteData(0xDF);
    LCDWriteCommand(0x2B);
    LCDWriteData(0x00);
    LCDWriteData(0x00);
    LCDWriteData(0x01);
    LCDWriteData(0x3F);
    LCDWriteCommand(0x2C);

    for(uint16_t i = 0; i < 480; i++) // Y
    {
        for(uint16_t j = 0; j < 320; j++)
        {
            if (i < 120)
            {
                LCDWriteData(RED>>8);
                LCDWriteData((uint8_t)RED);
            }
            else if (i < 240)
            {
                LCDWriteData(BLUE>>8);
                LCDWriteData((uint8_t)BLUE);
            }
            else if (i < 360)
            {
                LCDWriteData(GREEN>>8);
                LCDWriteData((uint8_t)GREEN);
            }
            else
            {
                LCDWriteData(YELLOW>>8);
                LCDWriteData((uint8_t)YELLOW);
            }
        }
    }
}
    
respondido por el user34920

Lea otras preguntas en las etiquetas