NT7603 i ustawianie adresu DDRAM

Hej,

Kupiłem na Allegro takiego LCD-ka:

formatting link
Jest tam kontroler NT7603, generalnie kompatybilny z HD44780:
formatting link
Problem: Każde ustawienie adresu DDRAM powyżej 40 i poniżej 48 (np. 43) ustawia go na 40, czyli znak pojawia się na początku drugiej linijki. Powyżej 48 w ogóle się nie pojawia. Dla pierwszej linijki wszystko jest w porządku.

Dostęp jest w trybie 4-bitowym.

Spotkaliście się z czymś takim?

Więcej info, jeżeli komuś chce się wgryzać:

Inicjalizuję wyświetlacz wysyłając bajty:

- 0x00 (dl=0: 4-bit)

- 0x08 (f=0: 5x8, n=1: 2line, dl=0: 4bit)

- 0x06 (i/d:1 increment, s=0: shift off)

- 0x14 (s/c=0: moe cursor, r/l=1: right)

- 0x01 (cls)

- 0x02 (home)

- 0x0C (d=1: display on)

Co ważniejsze funkcje (przejrzałem je kilka razy, ale może coś przeoczyłem?).

void lcd_goto(uint8_t x, uint8_t y) { send_byte(RS_C, 0x80 + ((y == 1) ? 40 : 0) + x); }

void lcd_printf(const char *fmt, ...) { char buf[17]; const char *p; va_list ap;

va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap);

for (p = buf; *p; ++p) send_byte(RS_D, *p); }

static void send_byte(bool isdata, uint8_t byte) { send_nibble(isdata, byte >> 4); send_nibble(isdata, byte & 0x0F); }

static void send_nibble(bool isdata, uint8_t nibble) { i2c_lcd_send(isdata, RW_W, false, nibble); i2c_lcd_send(isdata, RW_W, true, nibble); i2c_lcd_send(isdata, RW_W, false, nibble);

// xxx zrobic na busy flag { uint16_t i; for (i = 0; i < 0x3FF; ++i) __asm__("nop"); } }

static void i2c_lcd_send(bool rs, bool rw, bool en, uint8_t nibble) { uint8_t bytes[2];

bytes[0] = _BV(7); // VDD -> bit7 bytes[0] |= (nibble & _BV(3)) >> 3; // D3 -> bit0 bytes[0] |= (nibble & _BV(2)) >> 1; // D2 -> bit1 bytes[0] |= (nibble & _BV(1)) << 1; // D1 -> bit2 bytes[0] |= (nibble & _BV(0)) << 3; // D0 -> bit3 bytes[0] |= en << 4; // EN -> bit4 bytes[0] |= rw << 5; // RW -> bit5 bytes[0] |= rs << 6; // RS -> bit6

bytes[1] = 0xFF; // unused

i2c_send(SLAVE, bytes, _countof(bytes)); }

Po wypełnieniu wyświetlacza wartościami X i uruchomieniu takiego kodu:

for (i = 0; i < 16; ++i) { lcd_goto(i, 0); lcd_printf("%X", i);

lcd_goto(i, 1); lcd_printf("%x", i); }

Pojawia się:

0123456789ABCDEF 7XXXXXXXXXXXXXXX
Reply to
Adam Wysocki
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.