#define RS RC0
#define RW RC1
#define E RC2
#define PSB RC3
#define RST RC4
//PORTD=DATA;
unsigned char COUNT3,COUNT2,COUNT1,COUNT,LCD_X,LCD_Y,LCD_DATA1,LCD_DATA2,LCD_DATA,F3,R1,F0;
const unsigned char TU_TAB1[]={
// 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xF0,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x18,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xBF,0xFF,0xDC,0x00,0x01,
0x80,0x00,0x1F,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xBF,0xFF,0xBC,0x00,0x01,
0x80,0x00,0x30,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x01,0x7F,0xFF,0xB8,0x00,0x01,
0x80,0x00,0x30,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x01,0x7F,0xFF,0x78,0x00,0x01,
0x80,0x00,0x19,0xFF,0xFE,0xC0,0x00,0x00,0x00,0x00,0x02,0xFF,0xFF,0x70,0x00,0x01,
0x80,0x00,0x18,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02,0xFF,0xFE,0xF0,0x00,0x01,
0x80,0x00,0x0C,0x01,0xFF,0x60,0x00,0x00,0x00,0x00,0x05,0xFF,0xFE,0xE0,0x00,0x01,
0x80,0x00,0x0C,0x7F,0xD0,0x20,0x00,0x00,0x00,0x00,0x05,0xFF,0xFD,0xE0,0x00,0x01,
0x80,0x00,0x06,0x00,0x0F,0xB0,0x00,0x00,0x00,0x00,0x0B,0xFF,0xFD,0xC0,0x00,0x01,
0x80,0x00,0x06,0x03,0xFC,0x10,0x00,0x00,0x00,0x00,0x0B,0xFF,0xFB,0xC0,0x00,0x01,
0x80,0x00,0x03,0x1F,0x00,0x18,0x00,0x00,0x00,0x00,0x17,0xFF,0xFB,0x80,0x00,0x01,
0x80,0x00,0x03,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x17,0xFF,0xF7,0x80,0x00,0x01,
0x80,0x00,0x01,0x80,0x00,0x0C,0x00,0x00,0x00,0x00,0x17,0xFF,0xF7,0x00,0x00,0x01,
0x80,0x00,0x01,0x80,0x00,0x04,0x00,0x00,0x00,0x00,0x09,0xFF,0xEF,0x00,0x00,0x01,
0x80,0x00,0x00,0xC0,0x00,0xF6,0x00,0x00,0x00,0x00,0x06,0x7F,0xEE,0x00,0x00,0x01,
0x80,0x00,0x00,0xC0,0x03,0xC2,0x00,0x00,0x00,0x00,0x01,0x9F,0xDE,0x00,0x00,0x01,
0x80,0x00,0x00,0x60,0x00,0x3B,0x00,0x00,0x00,0x00,0x00,0x67,0xDF,0x00,0x00,0x01,
0x80,0x00,0x00,0x60,0x00,0xE3,0x00,0x00,0x00,0x00,0x00,0x19,0xBF,0x00,0x00,0x01,
0x80,0x00,0x00,0x30,0x03,0x8E,0x00,0x00,0x00,0x00,0x00,0x06,0x3F,0x00,0x00,0x01,
0x80,0x00,0x00,0x30,0x06,0x3C,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0x00,0x00,0x01,
0x80,0x00,0x00,0x18,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x01,
0x80,0x00,0x00,0x18,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x0F,0x7F,0x80,0x00,0x01,
0x80,0x00,0x00,0x0C,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x1F,0xC0,0x00,0x01,
0x80,0x00,0x00,0x0C,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x07,0xE0,0x00,0x01,
0x80,0x00,0x00,0x06,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x1F,0xE0,0x00,0x01,
0x80,0x00,0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x3F,0xC0,0x00,0x01,
0x80,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0xFF,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFC,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x05,0x40,0x88,0x04,0x01,0x08,0x00,0x00,0x0A,0x81,0x10,0x04,0x00,0x20,0x01,
0x80,0x79,0x21,0x08,0x02,0x21,0x49,0x00,0x00,0xF2,0x42,0x10,0x04,0x47,0x10,0x01,
0x80,0x09,0x07,0xDF,0x7F,0xF7,0xAA,0x00,0x00,0x12,0x0F,0xBE,0x7F,0xE5,0xFE,0x01,
0x80,0x7F,0xF4,0x51,0x08,0x81,0x2C,0x00,0x00,0xFF,0xE8,0xA2,0x44,0x47,0x00,0x01,
0x80,0x09,0x04,0x61,0x08,0x81,0x7F,0x00,0x00,0x12,0x08,0xC2,0x7F,0xC5,0x4A,0x01,
0x80,0x0B,0x24,0x51,0x08,0x83,0x81,0x00,0x00,0x16,0x48,0xA2,0x44,0x45,0x6A,0x01,
0x80,0x1D,0x47,0xC9,0x05,0x05,0x01,0x00,0x00,0x3A,0x8F,0x92,0x44,0x47,0x52,0x01,
0x80,0x68,0x84,0x49,0x05,0x05,0x7F,0x00,0x00,0xD1,0x08,0x92,0x7F,0xC5,0x6A,0x01,
0x80,0x09,0x94,0x41,0x02,0x01,0x01,0x00,0x00,0x13,0x28,0x82,0x44,0x05,0x4A,0x01,
0x80,0x0E,0x57,0xC1,0x0D,0x81,0x01,0x00,0x00,0x1C,0xAF,0x82,0x04,0x29,0x42,0x01,
0x80,0x38,0x34,0x4E,0x70,0x71,0x7F,0x00,0x00,0x70,0x68,0x9C,0x03,0xEB,0x7E,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
};
//*************delay_ms********************************
void delay_10us(unsigned char x)
{
while(x--);
}
void delay_ms(unsigned char cnt)
{
unsigned char i;
do {
i = 4;
do {
delay_10us(39);
} while(--i);
} while(--cnt);
}
//***********检查是否LCD忙碌的子程序**********************
void check_busy(void)
{
TRISD=0xff;//在此处设为输入。
PORTD=0xff;
RS=0;
RW=1;
while (1)
{
NOP();NOP();NOP();
E =1;
NOP();NOP();NOP();
if (RD7==0) break;
NOP();NOP();NOP();
E =0;
}
E =0;
TRISD=0X00;//还原为输出。
RC7=!RC7;
//delay_ms(50);
}
//**********数据写命令***************************
void send_com(unsigned char command )
{
check_busy();
RS=0;
RW=0;
PORTD=command;
E =1;
NOP();
NOP();
E =0;
}
//**********LCD初始化时的送命令******************
void send_com_init(unsigned char command_init )
{
RS=0;
RW=0;
PORTD=command_init;
E =1;
NOP();
NOP();
E =0;
}
//**********写数据***************************
void send_data(unsigned char data )
{
check_busy();
RS=1;
RW=0;
PORTD=data;
E =1;
NOP();
NOP();
E =0;
}
//***********读数据****************************
unsigned char read_data(void)
{
unsigned char read_data;
check_busy();
TRISD=0XFF;
RS=1;
RW=1;
E =1;
NOP();
read_data=PORTD;
E =0;
TRISD=0x00;//还原为输出。
return (read_data);
}
//***********Clear screen********************************
void clear_LCD(void)
{
send_com(0x01);
send_com(0x34);
send_com(0x30);
}
//**********LCD initialization****************************
void initial_LCD(void)
{
PSB=1;
RST=0;//Reset.
NOP();
NOP();
RST=1;
NOP();
delay_10us(10);
send_com_init(0x30);//30H--basic instruction operation
delay_10us(4);
send_com_init(0x0c);//Turn on display, turn off cursor, no blinking.
delay_10us(10);
send_com_init(0x01);//Clear display
delay_ms(10);
send_com_init(0x06);//Specify the direction of cursor movement when writing or reading data, and add 1 to the address counter (AC) of DDRAM.
}
//**********Write preparation******************************
void WR_ZB(void)
{
send_com(0x34);
send_com(LCD_Y);
send_com(LCD_X);
send_com(0x30);
}
//*********Get data and send to display**********************************
void QUSHU(const unsigned char *shu)
{
for (;COUNT!=0;COUNT--)
{
send_data(*shu++);
delay_ms(80);
}
}
//*********Flash******************************
void flash(void)
{
send_com(0x08);//Turn off display
delay_ms(250);
send_com(0x0c);//Turn on display, turn off cursor, no blinking.
delay_ms(250);
send_com(0x08);//Turn off display
delay_ms(250);
send_com(0x0c);//Turn on display, turn off cursor, no blinking.
delay_ms(250);
send_com(0x08);//turn off display
delay_ms(250);
}
//**********Display graphics subroutine************************
void PHO_DISP(const unsigned char *s)
{
COUNT3=0X02;
LCD_X=0X80;
for (;COUNT3!=0;COUNT3--)
{
LCD_Y=0X80;
COUNT2=0X20;//32
for (;COUNT2!=0;COUNT2--)
{
COUNT1=0X10;//16
WR_ZB();
for (;COUNT1!=0;COUNT1--)
{
send_data(*s++);
}
LCD_Y+=1;
}
LCD_X=0X88;
}
send_com(0x36);
send_com(0x30);
}
//******************Display dot matrix subroutine************
void LAT_DISP(void)
{
COUNT3=0X02;
LCD_X=0X80;
for (;COUNT3!=0;COUNT--)
{
LCD_Y=0X80;
F0=0;
COUNT2=0X20;
for (;COUNT2!=0;COUNT--)
{
COUNT1=0X10;
WR_ZB();
if (F0!=0)
{
LCD_DATA=LCD_DATA2;
}
else LCD_DATA=LCD_DATA1;
for (;COUNT1!=0;COUNT1--)
{
send_data(LCD_DATA);
}
LCD_Y+=1;
F0=!F0;
}
LCD_X=0X88;
}
send_com(0x36);
send_com(0x30);
}
void main(void)
{
TRISC=0X00;
TRISD=0X00;
PORTD=0X00;
PORTC=0X00;
initial_LCD();
while (1)
{
clear_LCD();
PHO_DISP(TU_TAB1);//显示图形
while (1);
}
}
Previous article:Four-digit digital tube dynamic display PROTEUS simulation based on PIC16F877
Next article:Simple Application of PIC Microcontroller ADC
Recommended ReadingLatest update time:2024-11-16 16:44
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
- Gossip negative feedback
- Do you think domestic regulators will prevent Nvidia from acquiring ARM?
- [Qinheng RISC-V core CH582] Application of ADC and general controller
- PFC switching power supply has these performance characteristics, do you know?
- Problems with encrypted transmission of STC microcontroller programs
- Issues that need attention when initializing SPI of C2000 series 280049 chip
- [Power amplifier case] Application of power amplifier based on voice coil motor test system design
- TI BMS Power Battery Management Technology: Why do batteries fail? How does BMS manage them?
- Music control board made by CircuitPython
- How to use Bluetooth 4.2 to implement the Internet of Things