微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > ATmega16 nokia7110 LCD 屏幕实验

ATmega16 nokia7110 LCD 屏幕实验

时间:11-13 来源:互联网 点击:

//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;ifor(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)
{
/* 启动数据传输 */
SPDR = d;
/* 等待传输结束 */
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 -

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top