Software: GCC V4.20 --------------------------------------------------------------- Experimental content: Write Lcd12864_ST7920. --------------------------------------------------------------- Hardware Connection: LCD12864_ST7920 ATmega128 1.GND -------- GND 2.VCC -------- VCC 3.V0 -------- NC 4.RS(CS) -------- PD7 5.R/W(SID) -------- PG0 6.E(SCLK) -------- PG1 7.D0 -------- PC0 8.D1 -------- PC1 9.D2 -------- PC2 10.D3 -------- PC3 11.D4 -------- PC4 12.D5 -------- PC5 13.D6 -------- PC6 14.D7 -------- PC7 15.PSB -------- VCC 16.NC -------- NC 17.RST -------- VCC 18.NC -------- NC 19.LED+ -------- VCC 20.LED- -------- GND The following is the program source code: ---------------------------------------------------------------*/ #include#include #include #define E_set PORTG|=_BV(PG1) //LCD enable #define E_clear PORTG&=~_BV(PG1) #define RW_set PORTG|=_BV(PG0) //LCD read and write #define RW_clear PORTG&=~_BV(PG0) #define RS_set PORTD|=_BV(PD7) //LCD data #define RS_clear PORTD&=~_BV(PD7) //LCD instruction unsigned char j=0; unsigned char yb=0x80; unsigned char name00[] PROGMEM={"Flying and shooting white deer in the snowy sky,"}; unsigned char name01[] PROGMEM={"Xiaoshu Shenxia Yibiyuan."}; unsigned char name02[] PROGMEM={"Heroes have always been extraordinary and eccentric since ancient times."}; unsigned char name03[] PROGMEM={"Mr. Jin writes with all his might."}; unsigned char name10[] PROGMEM={"Li Bai is about to set off on a boat,"}; unsigned char name11[] PROGMEM={"Suddenly I heard singing on the shore."}; unsigned char name12[] PROGMEM={"The water depth of Taohuatan is a thousand feet,"}; unsigned char name13[] PROGMEM={"Not as good as the love Wang Lun gave me."}; unsigned char name20[] PROGMEM={"this is a 12864 "}; unsigned char name21[] PROGMEM={"display program,"}; unsigned char name22[] PROGMEM={"welcome to commu"}; unsigned char name23[] PROGMEM={"nicate with me! "}; void wr_com(unsigned char); void wr_data(unsigned char); void reset (void); void outChinese(unsigned char,unsigned char,unsigned char *point); void ydgb(void); void outchar(unsigned char,unsigned char,unsigned char *point); void wr_com(unsigned char value)//Write instruction, RS=0;RW=0 must be used when writing instruction; { E_clear; RS_clear; RW_clear; _delay_ms(1); PORTC=value; //Incorporate character data E_set; _delay_ms(2); //If there is no delay, a busy check instruction must be added E_clear; } void wr_data(unsigned char sj)//Write data, RS=1;RW=0 must be set when writing data; { E_clear; RS_set; RW_clear; _delay_ms(1); PORTC=sj; E_set; _delay_ms(1); //If there is no delay, a busy check instruction must be added E_clear; } void reset (void) { wr_com(0x01);//Clear screen wr_com(0x08); //Display off wr_com(0x03);//Return wr_com(0x30); //Function setting wr_com(0x0f); //Open the display wr_com(0x01);//Clear screen } //**************** //outChinese is the function name //place is the first address of the displayed address //unit character length //charcode[] to display the content of the data [page] void outChinese(unsigned char place,unsigned char unit,unsigned char *point) { unsigned char i,progdata; wr_com(place); for(i=0;i
Previous article:4*4 matrix keyboard scanning and LED display program based on AVR
Next article:Summary of ATmega8's Analog Comparator
Recommended ReadingLatest update time:2024-11-17 00:21
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
- DSP28335 burning program, besides CCS software, is there any third-party program download software tool? ?
- What do the front-line people think: In 2022, the local IC industry will face a "big test"
- 【Awarded】Rewarded Survey——We want you! What does a good reference design website look like?
- Global UWB device shipments to reach 317 million
- Share a STLINK V2_1 PCB project, which can be directly sampled and produced
- Is there anyone familiar with ST's BLUENRG-LP? I would like to ask a question
- STM32 Global Unique ID Reading Method
- Qualcomm wins injunction, Chinese court bans sale of several iPhones
- RF microwave - Qorvo has a good interpretation of this material [gallium arsenide and gallium nitride]
- The domestic Gaoyun FPGA GWIN-4B development board cannot use the MSPI pin. Please help