ATmega16 nokia7110 LCD screen experiment

Publisher:JoyfulLifeLatest update time:2016-08-21 Source: eefocusKeywords:ATmega16  nokia7110  LCD Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The screen controller uses the SED1565 series

LCD pin

pin1 Temp sensor 47k (at 25C)
pin2 _CS
pin3 Speaker_p
pin4 D/_C
pin5 SCLK (max. 3.2MHz at Vlogic=+2.8V)
pin6 Speaker_n
pin7 On/Off
pin8 Led -
pin9 Led +
pin10 Gnd
pin11 Gnd
pin12 Vlogic (+ 2.8V)
pin13 SDATA
pin14 _RESET

##################################

pin 2 : Chip Select (CS)

pin 4 : Control/Display data flag (CD) 
        tsetup minimum 150 ns
        thold minimum 150 ns 
        low for Control data
        high for Display data

pin 5 : Serial Clock (SCL). 
           tcycle minimum 250 ns
           thigh minimum 100 ns
           tlow   minimum 100 ns

pin 11: GND

pin 12: VDD
        2.7 to 3.3 volts
        200 uA max.

pin 13: Serial Data (SDA).

pin 14: Reset

######################################

 

  ATmega16 nokia7110 LCD screen experiment Proteus Next article Display Chinese characters - liuyunqian@yeah - Embedded Learning

 

LCD Pin Connections
  ATmega16 nokia7110 LCD screen experiment Proteus Next article Display Chinese characters - liuyunqian@yeah - Embedded Learning


Display numbers and letters

 

  ATmega16 nokia7110 LCD screen experiment Proteus Next article Display Chinese characters - liuyunqian@yeah - Embedded Learning
The LCD communicates with the MCU via the SPI interface.

The program will be uploaded tomorrow, but it is not perfect yet. I am going to sleep now. I am so sleepy.

#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)

/********************************************************
              ASCII table for 5x7 dots font
********************************************************/
#pragma data:code
uchar const TABLE5 [240] = {
                  0x00,0x00,0x00,0x00,0x00, // 20 space
                  0x00,0x00,0x5f,0x00,0x00, // 21 !
                  0x00,0x07,0x00,0x07,0x00, // 22 "
                  0x14,0x7f,0x14,0x7f,0x14, // 23 #
                  0x24,0x2a,0x7f,0x2a,0x12, // 24 $
                  0x23,0x13,0x08,0x64,0x62, // 25 %
                  0x36,0x49,0x55,0x22,0x50, // 26 &
                  0x00,0x05,0x03,0x00,0x00, // 27 '
                  0x00,0x1c,0x22,0x41,0x00, // 28 (
                  0x00,0x41,0x22,0x1c,0x00, // 29 )
                  0x14,0x08,0x3e,0x08,0x14, // 2a *
                  0x08,0x08,0x3e,0x08,0x08, // 2b +
                  0x00,0x50,0x30,0x00,0x00, // 2c ,
                  0x08,0x08,0x08,0x08,0x08, // 2d -
                  0x00,0x60,0x60,0x00,0x00, // 2e .
                  0x20,0x10,0x08,0x04,0x02, // 2f /
                  0x3e,0x51,0x49,0x45,0x3e, // 30 0
                  0x00,0x42,0x7f,0x40,0x00, // 31 1
                  0x42,0x61,0x51,0x49,0x46, // 32 2
                  0x21,0x41,0x45,0x4b,0x31, // 33 3
                  0x18,0x14,0x12,0x7f,0x10, // 34 4
                  0x27,0x45,0x45,0x45,0x39, // 35 5
                  0x3c,0x4a,0x49,0x49,0x30, // 36 6
                  0x01,0x71,0x09,0x05,0x03, // 37 7
                  0x36,0x49,0x49,0x49,0x36, // 38 8
                  0x06,0x49,0x49,0x29,0x1e, // 39 9
                  0x00,0x36,0x36,0x00,0x00, // 3a :
                  0x00,0x56,0x36,0x00,0x00, // 3b ;
                  0x08,0x14,0x22,0x41,0x00, // 3c <
                  0x14,0x14,0x14,0x14,0x14, // 3d =
                  0x00,0x41,0x22,0x14,0x08, // 3e >
                  0x02,0x01,0x51,0x09,0x06, // 3f ?
                  0x32,0x49,0x79,0x41,0x3e, // 40 @
                  0x7e,0x11,0x11,0x11,0x7e, // 41 A
                  0x7f,0x49,0x49,0x49,0x36, // 42 B
                  0x3e,0x41,0x41,0x41,0x22, // 43 C
                  0x7f,0x41,0x41,0x22,0x1c, // 44 D
                  0x7f,0x49,0x49,0x49,0x41, // 45 E
                  0x7f,0x09,0x09,0x09,0x01, // 46 F
                  0x3e,0x41,0x49,0x49,0x7a, // 47 G
                  0x7f,0x08,0x08,0x08,0x7f, // 48 H
                  0x00,0x41,0x7f,0x41,0x00, // 49 I
                  0x20,0x40,0x41,0x3f,0x01, // 4a J
                  0x7f,0x08,0x14,0x22,0x41, // 4b K
                  0x7f,0x40,0x40,0x40,0x40, // 4c L
                  0x7f,0x02,0x0c,0x02,0x7f, // 4d M
                  0x7f,0x04,0x08,0x10,0x7f, // 4e N
                  0x3e,0x41,0x41,0x41,0x3e}; // 4f O

uchar const TABLE6 [240] = {
                  0x7f,0x09,0x09,0x09,0x06, // 50 P
                  0x3e,0x41,0x51,0x21,0x5e, // 51 Q
                  0x7f,0x09,0x19,0x29,0x46, // 52 R
                  0x46,0x49,0x49,0x49,0x31, // 53 S
                  0x01,0x01,0x7f,0x01,0x01, // 54 T
                  0x3f,0x40,0x40,0x40,0x3f , // 55 U
                  0x1f,0x20,0x40,0x20,0x1f, // 56 V
                  0x3f,0x40,0x38,0x40,0x3f, // 57 W
                  0x63,0x14,0x08,0x14,0x63, // 58 X
                  0x07,0x08,0x70,0x08,0x07, // 59 Y
                  0x61,0x51,0x49,0x45,0x43, // 5a Z
                  0x00,0x7f,0x41,0x41,0x00, // 5b [
                  0x02,0x04,0x08,0x10,0x20, // 5c 55
                  0x00,0x41,0x41,0x7f,0x00, // 5d ]
                  0x04,0x02,0x01,0x02,0x04, // 5e ^
                  0x40,0x40,0x40,0x40,0x40, // 5f _
                  0x00,0x01,0x02,0x04,0x00, // 60 `
                  0x20,0x54,0x54,0x54,0x78, // 61 a
                  0x7f,0x48,0x44,0x44,0x38, // 62 b
                  0x38,0x44,0x44,0x44,0x20, // 63 c
                  0x38,0x44,0x44,0x48,0x7f, // 64 d
                  0x38,0x54,0x54,0x54,0x18, // 65 e
                  0x08,0x7e,0x09,0x01,0x02, // 66 f
                  0x0c,0x52,0x52,0x52,0x3e, // 67 g
                  0x7f,0x08,0x04,0x04,0x78, // 68 h
                  0x00,0x44,0x7d,0x40,0x00, // 69 i
                  0x20,0x40,0x44,0x3d,0x00, // 6a j
                  0x7f,0x10,0x28,0x44,0x00, // 6b k
                  0x00,0x41,0x7f,0x40,0x00, // 6c l
                  0x7c,0x04,0x18,0x04,0x78, // 6d m
                  0x7c,0x08,0x04,0x04,0x78, // 6e n
                  0x38,0x44,0x44,0x44,0x38, // 6f o
                  0x7c,0x14,0x14,0x14,0x08, // 70 p
                  0x08,0x14,0x14,0x18,0x7c, // 71 q
                  0x7c,0x08,0x04,0x04,0x08, // 72 r
                  0x48,0x54,0x54,0x54,0x20, // 73 s
                  0x04,0x3f,0x44,0x40,0x20, // 74 t
                  0x3c,0x40,0x40,0x20,0x7c, // 75 u
                  0x1c,0x20,0x40,0x20,0x1c, // 76 v
                  0x3c,0x40,0x30,0x40,0x3c, // 77 w
                  0x44,0x28,0x10,0x28,0x44, // 78 x
                  0x0c,0x50,0x50,0x50,0x3c, // 79 y
                  0x44,0x64,0x54,0x4c,0x44, // 7a z
                  0x00,0x08,0x36,0x41,0x00, // 7b {
                  0x00,0x00,0x7f,0x00,0x00, // 7c |
                  0x00,0x41,0x36,0x08,0x00, // 7d }
                  0x10,0x08,0x08,0x10,0x08, // 7e ~
                  0x78,0x46,0x41,0x46,0x78}; // 7f ¦

                  //7e,43,40,43,7e //Ü
                  //7e,43,42,43,7e //Ö
                  //1e,21,21,71,21 //Ç
                  //3c,42,53,53,72 //Ð


/************************************************ *********
               Global Variable
***************************************** **********************/
#pragma data:data
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);
void lcd_chr(uchar charsel);
//void nokia_reset();
//void nokia_cls();
//void nokia_init();
void delay_ms(uint t)
{
   uint i,j;
    for(i=0;i    for(j=0;j<100;j++);
}

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);
   
   //SPCR=(0<<7)|(1<<6)|(0<<5)|(1<<4)|(0<<3)|(1<<2)|(1<<1)|(1);
//    SPIE   SPE    DORD MSTR    CPOL   CHPA   SPR1 SPR0 
}

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); // (0xA1 reverse lcd - 0xA0 select normal)
   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 -

char col_addr;
nokia_write_command(0xB0 + lcd_row);    // page address set. pg 8-48 in the datasheet.
col_addr = 0x12+(lcd_col*6);      // 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
}

/**********************************************************
           Convert bitmap to charractor Function
**********************************************************/
void lcd_chr(uchar charsel) 
{
   if (charsel < 0x20) return;
   if (charsel > 0x7f) return;

   for (char_row = 0; char_row < 5; char_row++) // 5 bytes
      {
         if (charsel<0x50)
   {
      charpos=(((charsel&0xff)-0x20)*5);
      chardata=TABLE5[(charpos+char_row)];
    }
         if (charsel>0x4f)
   {
      charpos=(((charsel&0xff)-0x50)*5);
      chardata=TABLE6[(charpos+char_row)];
    }
         nokia_write_data(chardata);            // send font data to lcd
      }
   nokia_write_data(0x00); // blank underline pixels for each font
}

/**********************************************************
Write a string at current screen position
**********************************************************/
void lcd_str(uchar *str) 
{
   while (*str)
    lcd_chr(*str++);
}
void main()
{
    DDRD=0XFF;
SPI_init();


nokia_init();
    
nokia_gotoxy(0,0);
    lcd_str("12345678abcdefg");

nokia_gotoxy(1,0);
    
lcd_str("abcdefg12345678");



//while(1);
}

Keywords:ATmega16  nokia7110  LCD Reference address:ATmega16 nokia7110 LCD screen experiment

Previous article:nokia7110 LCD display Chinese characters
Next article:AVR ATmega16 access 16-bit registers

Recommended ReadingLatest update time:2024-11-16 14:38

LCD TFT liquid crystal display principle and DID screen characteristics analysis
Liquid crystal display principle and structure? Liquid crystal is a substance that is both like a liquid (can flow) and like a crystal (has the optical properties of a crystal). The arrangement of liquid crystal molecules has a certain order, and the arrangement of liquid cryst
[Power Management]
In September, the capacity utilization rate of LCD panel factories in mainland China fell below 90%
Data from market research firm CINNO Research showed that the average capacity utilization rate of LCD panel factories in mainland China was 88.3% in September, falling below 90% for the first time in 15 months. BOE had the largest production cut of 10%, with its capacity utilization rate falling to around 83%. Althou
[Mobile phone portable]
Ultrasonic LCD1602 liquid crystal display distance C language program based on 51 single chip microcomputer 89C51
#include     #include intrins.h     #define uint unsigned int     #define uchar unsigned char     sbit rs=P1^2;     sbit rw=P1^1;     sbit en=P1^0;     char idata disp_buf1 ; //1602 display buffer 1 (i.e. the upper 16 characters)     char idata disp_buf2 ; //1602 display buffer 2 (i.e. the bottom 16
[Microcontroller]
ARM embedded LCD driver display picture
Kernel version: linux-3.4.2 lcd: 4.3 Before I go into the code, I have to explain some basic knowledge points. For LCD driver, we only need to write the code for the hardware. The following three functions have been written by the kernel for us. We only need to call them. These functions implement the data transmiss
[Microcontroller]
AVR microcontroller (learning) - (IV), ATMEGA16 timer/counter - 02
4. ATMEGA16 Timer/Counter 4-(02) T/C1 timer A/B compare match interrupt and overflow interrupt to realize automatic adjustment of LED brightness Ah~~~~~ Picture~~~~~ There is nothing to note here, just understand and control the two compare match interrupts A/B and overflow interrupts of T/C1, that's all ~~ Then the s
[Microcontroller]
AVR microcontroller (learning) - (IV), ATMEGA16 timer/counter - 02
89c52 MCU + HT1621 LCD driver
The microcontroller source program is as follows: #ifndef  _HT1621B_H_ #define  _HT1621B_H_ #include reg52.h #include intrins.h //In order to use NOP #define NOP _nop_() #define uchar unsigned char #define uint unsigned int #define ComMode 0x52  //4COM,1/3bias 1000 010 1001 0 #define RCosc 0x30 //Internal RC oscillat
[Microcontroller]
Section 002_S3C2440_LCD Controller
LCD controller main functions and required settings: Get: Get the data of a certain pixel from the memory (FrameBuffer); then tell the LCD controller the FrameBuffer address, BPP, and resolution; Send: send FrameBuffer data to LCD in conjunction with other signals; need to set LCD controller timing and pin polarity;
[Microcontroller]
Section 002_S3C2440_LCD Controller
Production of single chip microcomputer driving LCD1602
The production of the specific circuit is very simple. Just connect two resistors, one is a 10 ohm backlight current limiting resistor, and the other is a 2K LCD plate voltage adjustment resistor. How to determine the resistance of these two resistors? The backlight is relatively simple. It is equivalent to connecting
[Microcontroller]
Production of single chip microcomputer driving LCD1602
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号