12864 LCD (ks0108) driver and simulation based on AVR microcontroller

Publisher:数据小巨人Latest update time:2016-10-18 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
12864 LCD driver and simulation based on AVR microcontroller - Hanhai Jinyue - Hanhai Jinyue
 
#include
#include
#define EN 0      
#define RS 1
#define CS1 2
#define CS2 3
unsigned char a[32]={
0xEF,0xFB,0xEF,0xFC,0x2F,0xFF,0x00,0x00,0x6F,0xFF,0xEF,0xDC,0xFF,0xEF,0xBD,0x73,
0x1D,0xBC,0xAD,0xDF,0xB5,0xE7,0x39,0xB8,0xBD,0x7F,0xBF,0xBF,0x3F,0xC0,0xFF,0xFF
};
 
unsigned char ying[32]={
0xFF,0xBF,0xFF,0xCF,0x03,0xF0,0xFB,0xBF,0xBB,0xBF,0x7B,0xBE,0xFB,0xB1,0xDA,0xBF,
0x39,0xBF,0xFB,0x9C,0xFB,0xAF,0xFB,0xB3,0xFB,0xBC,0x1B,0xBF,0xFB,0xBF,0xFF,0xFF/*"应",0*/
};
unsigned char peng[32]={
0xFF,0x7F,0xFF,0x9F,0x01,0xE0,0xDD,0xFD,0xDD,0xBD,0xDD,0x7D,0x01,0x80,0xFF,0x7F,
0xFF,0x9F,0x01,0xE0,0xDD,0xFD,0xDD,0xBD,0xDD,0x7D,0x01,0x80,0xFF,0xFF,0xFF,0xFF/*"朋",0*/
};
unsigned char sbily1988[80]={0xFF,0xFF,0xFF,0xCC,0x7F,0xDB,0x7F,0xDB,0x7F,0xDB,0x7F,0xDB,0x7F,0xE6,0xFF,0xFF,/*"s",0*/
 
0xF7,0xFF,0x07,0xC0,0xFF,0xEE,0x7F,0xDF,0x7F,0xDF,0xFF,0xEE,0xFF,0xF1,0xFF,0xFF,/*"b",1*/
 
0xFF,0xFF,0x7F,0xDF,0x67,0xDF,0x67,0xC0,0xFF,0xDF,0xFF,0xDF,0xFF,0xFF,0xFF,0xFF,/*"i",2*/
 
0xFF,0xFF,0xF7,0xDF,0xF7,0xDF,0x07,0xC0,0xFF,0xDF,0xFF,0xDF,0xFF,0xFF,0xFF,0xFF,/*"l",3*/
 
0x7F,0x7F,0x7F,0x7E,0x7F,0x71,0xFF,0x8F,0xFF,0xE7,0x7F,0xF9,0x7F,0xFE,0x7F,0xFF,/*"y",4*/
};
 
void init();
void wcom(unsigned char);
void wdata(unsigned char);
void show(unsigned char data[],unsigned char,unsigned char,unsigned char);
void main()
{
 heat();
 while(1)
  { 
  show(which,32,0xb9,0xb8);
  show(ying,32,0xbb,0xba);
  show(peng,32,0xbd,0xbc);
  show(sbily1988,80,0xbf,0xbe);
  while(1);
}
}
void init() //initialization function
{
 DDRC=0xff; DDRD=0xff;
 PORTC=0xff; PORTD=0xff;
 wcom(0x3f); //Turn on LCD display
 PORTD|=BIT(CS1); //Turn off the right half plane display
 PORTD&=~BIT(CS2); //Open the left half plane display
}
void wcom(unsigned char data) //write command
{
 PORTD|=BIT(ONE);
 PORTD&=~BIT(RS);
 PORTC=data;
 PORTD&=~BIT(EN);
 PORTD|=BIT(RS);
}
void wdata(unsigned char data) //write data
{
 PORTD|=BIT(ONE);
 PORTD|=BIT(RS);
 PORTC=data;
 PORTD&=~BIT(EN);
 PORTD&=~BIT(RS);
}
void show(unsigned char data[],unsigned char sum,unsigned char a,unsigned char b)//显示函数
{ /*data[], font first address; sum, array length; a, next page; b previous page*/
  unsigned char i;
  for(i=0;i
    {
  if(i%2) {wcom(a); wcom(0x40+(i/2));}
else {wcom(b);wcom(0x40+(i-1)/2+1);}
 wdata(data[i]);  
}
}
 
Postscript: I used iccavr7.22 version. I wanted to make the font into a table and put it in flash. I tried it according to the method on the Internet.
1)“const unsigned  char a[]={};
2)#pragma data:code
     const unsigned char a[]={};
  #pragma data:data
"All failed. In the first case, the compilation passed, but after compilation, I found that it still defined the array in RAM.
                   In the second case, the compilation fails and the message "cannot initialize RAM area" is always displayed.
Later I searched online for a long time and tried again flash unsigned char a[]={};
This time the compilation passed and it is easy to see that it is indeed in the flash
   Area                               Addr   Size   Decimal Bytes (Attributes)
--------------------------------   ----   ----   ------- ----- ------------
                             lit   0054   00B0 =    176. bytes (rel,con,rom)
 
       Addr  Global Symbol
      -----  --------------------------------
       0054  __lit_start
       0054 _the
       0074  _ying
       0094  _peng
       00B4  _sbily1988
       0104  __lit_end
Here lit means it exists in flash. But one thing needs to be noted, if it is defined with flash unsigned char, the data type of the function parameter must also be flash unsigned char, otherwise an error will occur.
Reference address:12864 LCD (ks0108) driver and simulation based on AVR microcontroller

Previous article:AVR IAP Function
Next article:AVR microcontroller serial port program based on Proteus simulation

Recommended ReadingLatest update time:2024-11-16 13:29

Design of high-precision electronic scale based on AVR microcontroller
0 Introduction With the continuous development of electronic technology and automated measurement technology, traditional weighing systems can no longer meet people's needs in terms of function, accuracy, cost performance, etc., especially in terms of intelligence, portability, and measurement of tiny masses. I
[Microcontroller]
Design of high-precision electronic scale based on AVR microcontroller
Creating Machine Life with AVR MCU
1 What is machine life? Machine life is a machine that can survive autonomously, a machine that automatically struggles to survive. For machine life, survival means continuing to run without power outages. Machine life has the characteristics of completely autonomous decision-making, autonomous actions, activit
[Microcontroller]
Creating Machine Life with AVR MCU
AVR single chip digital tube display clock program
//Digital tube data P0 port, digital tube control P2 port #include avr/io.h #include avr/delay.h #include avr/pgmsPACe.h #include avr/signal.h #include avr/interrupt.h #define code PROGMEM #define uchar unsigned char #define uint  unsigned int code const uchar LED_7 = {0x28, 0x7E, 0xA2, 0x62, 0x74, 0x61, 0x21, 0x7A
[Microcontroller]
PIC microcontroller drives LCD12864 liquid crystal display flashing font program
/****************************************************** ********************* *** Function: 12864LCD display shows flashing fonts, students can modify it by themselves. *** Experimental content: 0x81 0x90 0x88 0x98 are the row start addresses of the four lines of LCD respectively. The characters we operate the LCD re
[Microcontroller]
How to design an SPI serial peripheral interface based on AVR microcontroller?
1. SPI interface of AVR microcontroller The SPI (Serial Peripheral INTERFACE) bus system is a synchronous serial peripheral interface that allows the MCU to communicate and exchange data with various peripheral devices in a serial manner. It is widely used in various industrial control fields. Based on this standard,
[Microcontroller]
How to design an SPI serial peripheral interface based on AVR microcontroller?
AVR MCU controls RTL8019AS to implement Ethernet interface design
Introduction: This article introduces a method of using AVR microcontroller to realize Ethernet interface circuit, which has few hardware circuits, simple structure and easy use. With the rapid development of the Internet, various household appliances and instruments are gradually becoming networked in order to shar
[Microcontroller]
AVR MCU controls RTL8019AS to implement Ethernet interface design
Design of information monitoring terminal using AVR single chip microcomputer and LCD module
At present, with the rapid development of the information industry, all kinds of ships are in urgent need of being equipped with more high-quality and low-cost small and medium-sized information monitoring terminals to monitor weather conditions and obtain navigation information to ensure navigation safety. 32-bit pro
[Microcontroller]
Design of information monitoring terminal using AVR single chip microcomputer and LCD module
Design of Presettable Programmable Broadband DC Power Amplifier Circuit Based on AVR Microcontroller
  This paper uses AVR single-chip microcomputer ATmegal28 as the core controller, combined with 10-bit serial D/A chip TLC5615, power amplifier THS3092, programmable gain amplifier AD603 and other related circuits to form a preset programmable broadband DC power amplifier circuit. The gain adjustment range of this cir
[Microcontroller]
Design of Presettable Programmable Broadband DC Power Amplifier Circuit Based on AVR Microcontroller
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号