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
######################################
LCD Pin Connections
Display numbers and letters
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
}
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); //
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);
}
Previous article:nokia7110 LCD display Chinese characters
Next article:AVR ATmega16 access 16-bit registers
Recommended ReadingLatest update time:2024-11-16 14:38
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
- How to read constant array in flash using IAR FOR AVR?
- Technology Live: MEMS sensors usher in a new era of condition monitoring, ADI takes you into the kingdom of cold machines
- Analysis of the working principles of seven triode collector DC circuits 3
- Explore RF challenges and solutions for the connected car
- 40 Years of Mobile Base Station History
- 【RT-Thread Reading Notes】Network Framework
- Altium Designer 17 version experience sharing (updated from time to time)
- EEWORLD University ---- Introduction to LED functions and considerations for LED driver design
- Please recommend 4G module
- [GD32E231 DIY Contest]——07. Getting Started with GD32E231C-START