Auratos 0 6 октября, 2014 Опубликовано 6 октября, 2014 (изменено) · Жалоба Добрый день. Буквально 3 недели назад начал работать с микроконтроллерами (конкретно в данный момент работаю с PIC18f25k22), а с ЖКИ PCF2119 - почти неделю. В данный момент стоит задача по созданию пользовательских символов. Я нашел пример в даташите по PCF2119, там символ записывается в 0-й адрес CGRAM. Подскажите, пожалуйста, как записать его в другой адрес? Просто если я сейчас разберусь с этим, то мне дальше это очень пригодится. Вот пример из даташита: // Write a user defined character into the CGRAM startI2C(); // PCF2119 slave address for write, SA0 is connected to Vdd SendI2CAddress(0x76); // MSB (Continuation bit Co) = 0, more than one byte may follow. Bit6, RS=0, next byte // is command byte i2c_write(0x00); // 2 lines x 16, 1/18 duty, basic instruction set. Next byte will be another command. i2c_write(0x24); // Set CGRAM address to 0 i2c_write(0x40); // Repeated Start condition startI2C(); SendI2CAddress(0x76); // RS=1, next byte is a data byte i2c_write(0x40); // Here the data bytes to define the character // Behind the write commands the 5x8 dot matrix is shown, the 1 represents a on pixel. // The Euro currency character can be recognized by the 0/1 pattern (see Figure 48) i2c_write(0x06); // 00110 i2c_write(0x09); // 01001 i2c_write(0x08); // 01000 i2c_write(0x1E); // 11110 i2c_write(0x1E); // 11110 i2c_write(0x08); // 01000 i2c_write(0x09); // 01001 i2c_write(0x06); // 00110 i2c_stop(); // Until here the definition of the character and writing it into the CGRAM. Now it // still needs to be displayed. See below. // PCF2119, setting of proper display modes startI2C(); // PCF2119 slave address for write, SA0 is connected to Vdd SendI2CAddress(0x76); // MSB (Continuation bit Co) = 0, more than one byte may follow. Bit6, RS=0, next byte // is command byte i2c_write(0x00); // 2 lines x 16, 1/18 duty, extended instruction set. Next byte will be another // command. i2c_write(0x25); // Set display configuration to right to left, column 80 to 1. Row data displ. top to // bottom,1 to 16. i2c_write(0x06); // Set to character mode, full display, icon blink disabled i2c_write(0x08); // Set voltage multiplier to 2 i2c_write(0x40); // Set Vlcd and store in register VA i2c_write(0xA0); // Change from extended instruction set to basic instruction set i2c_write(0x24); // Display control: set display on, cursor off, no blink i2c_write(0x0C); // Entry mode set, increase DDRAM after access, no shift i2c_write(0x06); // Return home, set DDRAM address 0 in address counter i2c_write(0x02); // Clear entire display, set DDRAM address to 0 in address counter i2c_write(0x01); // Repeated Start condition because RS needs to be changed from 0 to 1 startI2C(); SendI2CAddress(0x76); // RS=1, next byte is data i2c_write(0x40); // Write the character at address 0, which is the previously defined Euro currency // character i2c_write(0x00); i2c_stop(); Как я понял, все дело в этих двух строчках: // Set CGRAM address to 0 i2c_write(0x40); ... // Write the character at address 0, which is the previously defined Euro currency character i2c_write(0x00); Вот только почитав про CGRAM, у меня не получилось разобраться с его битами адреса Изменено 10 октября, 2014 пользователем IgorKossak [codebox] для длинного кода, [code] - для короткого!!! Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
Auratos 0 7 ноября, 2014 Опубликовано 7 ноября, 2014 · Жалоба На другом форуме мне помогли разобраться с данной проблемой. Вот цитата: "Три младших бита в CGRAM адресе выбирают номер строки в символе, то есть символ 5 колонок на 8 строк. Более старшие биты определяют адрес символа. Таким образом адреса: 0х00 - первый пользовательский символ 0х08 - второй пользовательский символ 0х10 - третий ... // CGRAM address для первого i2c_write( 0x40 ); // Set CGRAM address для второго i2c_write( 0x48 ); // Set CGRAM address для третьего i2c_write( 0x50 ); и т.д." Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться