As for the lines that appear in the lower right corner of the screen, it may be a bug in proteus
The procedure is as follows
#include
#include "stdio.h"
#define uchar unsigned char
#define uint unsigned int
#define CLR_CS PORTD&=~(1<<0)
#define SET_CS PORTD|=(1<<0)
#define CLR_DC PORTD&=~(1<<1) //low for Control data high for Display data
#define SET_DC PORTD|=(1<<1)
#define CLR_RESET PORTD&=~(1<<2)
#define SET_RESET PORTD|=(1<<2)
uchar HZ[][32]={{0xFF,0xBF,0x4D,0x69,0x65,0x6D,0x09,0x65,0x6C,0x6E,0x66,0x68,0x6E,0x6F,0xCF,0xFF,0xBF,0xDF,0x5F,0x6F, 0xB3,0xB8,0xD5,0xD5,0xED,0xE5,0xD9,0xDD,0xBF,0x3F,0xBF,0xFF},/*"爱",0*/
{0xDF,0xDF,0xDD,0xDD,0x01,0xDE,0xDE,0xDF,0xDF,0x00,0xDF,0xDD,0x53,0xDF,0xDF,0xFF,0xFB,0xFB,0xBD,0x7D,0x80,0xFE,0xFE,0xEF,0xEF,0xF7,0xF8,0xE5,0xDE,0xBF,0x0F,0xFF},/*"我",1*/
{0xFF,0xFF,0x03,0xF7,0xF7,0xF7,0xF7,0x00,0xF7,0xF7,0xF7,0xF7,0x03,0xF7,0xFF,0xFF,0xFF,0xFF,0xF8,0xFD,0xFD,0xFD,0xFD,0x00,0xFD ,0xFD,0xFD,0xFD,0xF8,0xFF,0xFF,0xFF},/*"中",2*/
{0xDF,0xEF,0xF7,0x03,0xFC,0xFD,0xEF,0xEF,0x80,0x77,0x77,0x7B,0x79,0x1B,0xFF,0xFF,0xFF,0xFB,0xFB,0xFA,0xFB,0xFB,0xFB,0x00,0xFB ,0xFB,0xFB,0xFB,0xFB,0xFB,0xFB,0xFF},/*"华",3*/
{0xDF,0xDF,0xDD,0xDD,0x01,0xDE,0xDE,0xDF,0xDF,0x00,0xDF,0xDD,0x53,0xDF,0xDF,0xFF,0xFB,0xFB,0xBD,0x7D,0x80,0xFE,0xFE,0xEF,0xEF,0xF7,0xF8,0xE5,0xDE,0xBF,0x0F,0xFF},/*"我",4*/
{0xFF,0x07,0x73,0x74,0x77,0x07,0xBF,0xCF,0x70,0xF7,0xF7,0xF7,0x07,0xFF,0xFF,0xFF,0x80,0xEF,0xEF,0xEF,0xC0,0xFF,0xFF,0xFF,0xFC,0xD9,0xBF,0xDF,0xE0,0xFF,0xFF},/*"的",5*/
{0xFF,0xE7,0xFB,0xEB,0x6B,0x6B,0x2A,0x49,0xEB,0xEB,0x6B,0xFB,0xEB,0xF3,0xFB,0xFF,0xFF,0xD6,0xD6,0xEA,0xEB,0xB5,0x76,0xBB,0xC0 ,0xF9,0xF6,0xF6,0xEF,0xCF,0xEF,0xFF}};
/************************************************ *********
Global Variable
*************************************** *******************/
uchar page;
uchar x,y;
uchar char_row;
uchar charpos;
uchar chardata;
void nokia_write_dorc(uchar bytefornokia);
void nokia_write_command(uchar bytefornokia_command);
void nokia_write_data(uchar bytefornokia_data);
void nokia_gotoxy(uchar xnokia, uchar ynokia);
void lcdpixel(uchar x, uchar y,uchar d);
void lcd_chr(uchar chars el) ;
void delay_ms(uint t)
{
uint i,j;
for(i=0;i
}
void SPI_init()
{
DDRB|=(1<<5)|(1<<7);//MOSI SCK OUTPUT
SPCR=(0<<7)|(1<<6)|(0<<5)| (1<<4)|(0<<3)|(0<<2)|(0<<1)|(1);
}
void SPI_sendB(uchar d)
{
/* Start data transfer*/
SPDR = d;
/* Wait for the transfer to end*/
while(!(SPSR & (1<
/************************************************ *******
Nokia clear LCD function
*************************************** *****************/
void nokia_cls() {
for (page=0; page<9; page++) // 9 page
{
nokia_write_command(0xB0 | page); // page address ie:0xB0,0xB1,...,0xB7
nokia_write_command(0x11); // most 4 bit column address command 0001 0011
nokia_write_command(0x02); // least 4 bit column address command 0000 0011
for (x=96; x> 0; x--) // 96 column
nokia_write_data(0x00);
}
}
/******************************** ****************************
Reset LCD Function
********************* *************************************/
void nokia_reset()
{
SET_RESET; //1
delay_ms(10);
CLR_RESET; //0
delay_ms(10);
SET_RESET; //1
delay_ms(100);
}
/************************************************ *********
Initial LCD Function
*************************************** ********************/
void nokia_init() {
nokia_reset();
nokia_write_command(0xA6); // lcd in normal display mode (0xA7 negative mode)
nokia_write_command(0xA3 ); // lcd bias (1/9 0xA2 - 1/7 0xA3)
nokia_write_command(0xA1); //
nokia_write_command(0xC0); // common output normal (0xC8 reverse )
nokia_write_command(0x22); // V5 resistor ratio
nokia_write_command(0x81); // electronic volume mode
nokia_write_command(0x2E); // power control set value (contrast level --> 0x00 lightest to 0x3F darkest)
nokia_write_command(0x2F); // power control set value
nokia_write_command(0xE3); // nop
nokia_write_command(0x40); // start line set
nokia_write_command(0xAF); // lcd on
nokia_write_command(0xA5); // lcd all points on
delay_ms(500);
nokia_write_command(0xAE); // lcd off
nokia_cls();
nokia_write_command(0xAF); // lcd on
nokia_write_command(0xA4); // lcd normal display mode
}
/************************************************ *********
sent 8 bit data to LCD by series
********************************* *************************/
void nokia_write_dorc(uchar bytefornokia)
{
SPI_sendB(bytefornokia);
}
/************************************************ *********
Sent Command to LCD Function
************************************ ************************/
void nokia_write_command(uchar bytefornokia_command)
{
CLR_DC; // lcd command mode
CLR_CS; // chip enabled
nokia_write_dorc(bytefornokia_command);
SET_CS; // chip disabled
}
/************************************************ *********
Sent Data to LCD Function
************************************ ************************/
void nokia_write_data(uchar bytefornokia_data) {
SET_DC; // display data mode
CLR_CS; // chip enabled
nokia_write_dorc(bytefornokia_data);
SET_CS; // chip disabled
}
/************************************************ *********
goto xy position on LCD Function
*********************************** ***********************/
void nokia_gotoxy(uchar lcd_row, uchar lcd_col)
{ //lcy_row: 0 - 8 (8th column has only 1 line / D0 , lcd_col: 0 -15
char col_addr;
nokia_write_command(0xB0 + lcd_row); // page address set. pg 8-48 in the datasheet.
col_addr = 0x12+(lcd_col); // each font has five columns + 1 blank column. xaddr: 0 - 95 on noki
//a 7110. no offset.
//lcd_1st_col=0x12: the first column of display starts here. Weird! the datasheet didn't mention it.
nokia_write_command(0x10 | (col_addr>>4)); // column address 4 most bit set
nokia_write_command(0x0f & col_addr); // column address 4 least bit set
}
/********************************** ***************************
Xie one byte at xy position
****************** ******************************************/
void lcdpixel(uchar x, uchar y,uchar d) // lower left corner is (0,0) x 0-75 has a bug
// y 0-63
{
nokia_gotoxy(x,y);
nokia_write_data(d);
}
void lcd_HZ(uchar x,uchar y,uchar *s)
{
uchar i;
y=y*16;
for(i=0;i<16;i++)
{
lcdpixel(x,y+i,s[i]);
}
for(i=16;i<32;i++)
{
lcdpixel(x+1,y+i-16,s[i]);
}
}
void main()
{
uchar i;
DDRD=0XFF;
SPI_init();
nokia_init();
//lcdpixel(1,0,0xaa);
for(i=0;i<8;i++)
lcd_HZ(0,i,HZ [i]);
//nokia_write_command(0xa5); //diaplay all points on
//while(1);
}
The font extraction is still done using PCtoLCD2000
################################################ ####################
The "home" above is not displayed
void main()
{
uchar i;
DDRD=0XFF;
SPI_init();
nokia_init();
//lcdpixel(1,0,0xaa);
for(i=0;i<6;i++)
lcd_HZ(0,i,HZ [i]);
lcd_HZ(2,0,HZ[6]);
//nokia_write_command(0xa5); //diaplay all points on
//while(1);
}
Previous article:Simple menu system Proteus pg12864 LCD
Next article:ATmega16 nokia7110 LCD screen experiment
Recommended ReadingLatest update time:2024-11-16 16:26
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- TMS320C5402 serial port initialization
- Some new changes that 5G brings to PA
- 【GD32E231 DIY】OLED usage (SPI)
- Let you know about brushless DC motor
- EETalk: What pitfalls have you encountered during PCB design?
- Harbin Institute of Technology and Harbin Engineering University are banned from using genuine MATLAB software. What do you think about this?
- How to design an RC oscillator circuit with an output frequency of 1k to 3.2MHz
- Will power management integrated circuits (PMIC) be the mainstream direction in the future?
- Some experience on DSP parallel FLASH booting
- Where can I find the meaning of TI chip suffixes?