Ssd1306 lcd (64x32) only half screen working

I have ssd1306 lcd with 64x32 resolutinon connected to I2C on STM32F103. I try to place some text and line on screen but see only half of data. I think something in my init code...

uint8_t SSD1306_Init(void) {

	/* Init I2C */
	ssd1306_I2C_Init();
	
	/* Check if LCD connected to I2C */
	if (!ssd1306_I2C_IsDeviceConnected(SSD1306_I2C, SSD1306_I2C_ADDR)) {
		/* Return false */
		return 0;
	}

    SSD1306_WRITECOMMAND(0xAE); //display off

    SSD1306_WRITECOMMAND(0x20); //Set Memory Addressing Mode
    SSD1306_WRITECOMMAND(0x00); //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid

    SSD1306_WRITECOMMAND(0xB0); //Set Page Start Address for Page Addressing Mode,0-7

    SSD1306_WRITECOMMAND(0xC0); //mirror vert
        SSD1306_WRITECOMMAND(0x40); //--set start line address

    SSD1306_WRITECOMMAND(0x81); //--set contrast control register
    SSD1306_WRITECOMMAND(0xFF);

    SSD1306_WRITECOMMAND(0xA0); //--set segment re-map 0 to 127

    SSD1306_WRITECOMMAND(0xA6); //--set normal display

    SSD1306_WRITECOMMAND(0xA8); //--set multiplex ratio(1 to 64)
    SSD1306_WRITECOMMAND(0x1F); //32 active line on display

    SSD1306_WRITECOMMAND(0xA4); //0xa4,Output follows RAM content;0xa5,Output ignores RAM content

    SSD1306_WRITECOMMAND(0xD3); //-set display offset
    SSD1306_WRITECOMMAND(0x00); //-not offset

    SSD1306_WRITECOMMAND(0xD5); //--set display clock divide ratio/oscillator frequency
    SSD1306_WRITECOMMAND(0xF0); //--set divide ratio

    SSD1306_WRITECOMMAND(0xD9); //--set pre-charge period
    SSD1306_WRITECOMMAND(0x22); //

    SSD1306_WRITECOMMAND(0xDA); //--set com pins hardware configuration
    SSD1306_WRITECOMMAND(0x12);

    SSD1306_WRITECOMMAND(0xDB); //--set vcomh
    SSD1306_WRITECOMMAND(0x20); //0x20,0.77xVcc

    SSD1306_WRITECOMMAND(0x8D); //--set DC-DC enable
    SSD1306_WRITECOMMAND(0x14); //
    SSD1306_WRITECOMMAND(0xAF); //--turn on SSD1306 panel

    /* Clear screen */
    SSD1306_Fill(SSD1306_COLOR_BLACK);
    
    /* Update screen */
    SSD1306_UpdateScreen();
    
    /* Set default values */
    SSD1306.CurrentX = 0;
    SSD1306.CurrentY = 0;
	
    /* Initialized OK */
    SSD1306.Initialized = 1;
	
    /* Return OK */
    return 1;
}

main code

char* strin3 = "01234567";
SSD1306_Init();
SSD1306_GotoXY(0,0);
SSD1306_Puts(strin3, &Font_7x10, 1);
SSD1306_UpdateScreen();

SSD1306_DrawLine(1,1,63,31,1);
SSD1306_UpdateScreen();

And what i see

I try some changes in init code and I can change the shift in the vertical direction, mirror in the vertical direction. And if I send 0xA5 (All indicator ON - Output ignores RAM parameter), then I see a full screen filled.

Welcome to the forum

Please post a complete sketch that illustrates the problem

I have never seen anything remotely like your code, so I guess you are not using a library. I imagine you will be alot better off if you did. While I'm not familiar with your particular device, I understand the Adafruit ASCII library covers several different versions of the SSD1306.

I got it. As i understand, this small displays active memory region for horizontal line is in the middle of memory region of 128x64. So i place all data in cols 32 to 96, and all seems good now.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.