您的位置 首页 培训

NOKIA3300五颜六色液晶测验程序

/*************AVR单片机学习板V1.1程序**************//*******************************************************

/*************AVR单片机学习板V1.1程序**************/

/*************************************************************/

/*****File Function : NOKIA3300液晶测验程序 *****/

/*****Program Author : ZhengWen(ClimberWin) *****/

/*****MCU : ATMEGA16L 外部12M晶振 *****/

/*****Compile Date : 2009/11/28 *****/

/*****Edition Info : V1.0 *****/

/*************************************************************/

/*功用描绘:NOKIA3300五颜六色液晶显现一幅图片,256色*/

//显现一幅图片112*112巨细

#include <avr/io.h>

#include

#include

#define uchar unsigned char

#define uint unsigned int

#define nop asm(“NOP”)

#define BIT7 0x80

#define BIT6 0x40

#define BIT5 0x20

#define BIT4 0x10

#define BIT3 0x08

#define BIT2 0x04

#define BIT1 0x02

#define BIT0 0x01

#define LCD_RET_H PORTB|=BIT3 //RESET —- PB3 //复位能够直接接到VCC

#define LCD_RET_L PORTB&=~BIT3

#define LCD_CS_H PORTB|=BIT4 //CS —- PB4

#define LCD_CS_L PORTB&=~BIT4

#define LCD_CLK_H PORTB|=BIT7 //CLK —- PB7

#define LCD_CLK_L PORTB&=~BIT7

#define LCD_DIN_H PORTB|=BIT5 //DIN —- PB5

#define LCD_DIN_L PORTB&=~BIT5

// Epson S1D15G10 Command Set

#define DISON 0xaf //display on

#define DISOFF 0xae //display off

#define DISNOR 0xa6 //display normal

#define DISINV 0xa7 //invers display

#define COMSCN 0xbb //

#define DISCTL 0xca

#define SLPIN 0x95

#define SLPOUT 0x94

#define PASET 0x75

#define CASET 0x15

#define DATCTL 0xbc

#define RGBSET8 0xce

#define RAMWR 0x5c

#define RAMRD 0x5d

#define PTLIN 0xa8

#define PTLOUT 0xa9

#define RMWIN 0xe0

#define RMWOUT 0xee

#define ASCSET 0xaa

#define SCSTART 0xab

#define OSCON 0xd1

#define OSCOFF 0xd2

#define PWRCTR 0x20

#define VOLCTR 0x81

#define VOLUP 0xd6

#define VOLDOWN 0xd7

#define TMPGRD 0x82

#define EPCTIN 0xcd

#define EPCOUT 0xcc

#define EPMWR 0xfc

#define EPMRD 0xfd

#define EPSRRD1 0x7c

#define EPSRRD2 0x7d

#define NOP 0x25

//显现112*112

unsigned char bmp[]PROGMEM ={

图片数据代码

};

void init_lcd (void);

void init_mcu (void);

void lcd_data (uchar data);

void lcd_command (uchar command);

static uchar color[]={0b11100000,0b00011100,0b00000011,0b11111100,0b11100011,0b00011111,0x00,0xff};

//界说了等下显现的8种色彩

//RGB332格局

int main (void)

{

uint num=0;

uchar x=0;

uchar i,j;

init_mcu ();

init_lcd ();

while(1)

{

lcd_command (PASET);

lcd_data (9);

lcd_data (111+9);

lcd_command (CASET);

lcd_data (11);

lcd_data (111+11);

lcd_command (RAMWR);

for (num=0;num<12544;num++)

lcd_data(pgm_read_byte(bmp+num));

while(1);

} //while循环

return (0);

}

void init_mcu (void) //初始化

{

DDRB=0xff;

PORTB=0xff;

_delay_us(1);

}

void lcd_data (uchar data)

{

LCD_CS_L;

LCD_CLK_L;

LCD_DIN_H; //数据

LCD_CLK_H;

SPCR=0x50;

SPDR=data;

while (!(SPSR & (1<

LCD_CS_H;

SPCR=0x00;

}

void lcd_command (uchar command)

{

LCD_CS_L;

LCD_CLK_L;

LCD_DIN_L; //指令

LCD_CLK_H;

SPCR=0x50;

SPDR=command;

while (!(SPSR & (1<

LCD_CS_H;

SPCR=0x00;

}

void init_lcd ()

{

LCD_RET_L;

nop;nop;

LCD_RET_H;

lcd_command (DISCTL);

lcd_data (0x0f);

lcd_data (0x20);

lcd_data (0x0f);

lcd_data (0x01);

lcd_command (COMSCN); //上下半图象扫描次序

lcd_data (0x01);

lcd_command (OSCON);

lcd_command (SLPOUT);

lcd_command (VOLCTR);

lcd_data (0x0e); //调整对比度,越大越亮

lcd_data (0x05); //色彩调整,5最合适

lcd_command (PWRCTR);

lcd_data (0x0f);

lcd_command (DISINV); //色彩次序

lcd_command (PTLOUT);

lcd_command (DATCTL);

lcd_data (0x01); //改动增量方向

lcd_data (0x01);

lcd_data (0x01);

lcd_command (RGBSET8); //调色板设置

lcd_data (0x00);

lcd_data (0x02);

lcd_data (0x04);

lcd_data (0x06);

lcd_data (0x08);

lcd_data (0x0a);

lcd_data (0x0c);

lcd_data (0x0f);

lcd_data (0x00);

lcd_data (0x02);

lcd_data (0x04);

lcd_data (0x06);

lcd_data (0x08);

lcd_data (0x0a);

lcd_data (0x0c);

lcd_data (0x0f);

lcd_data (0x00);

lcd_data (0x06);

lcd_data (0x09);

lcd_data (0x0f);

lcd_command (DISON); //开显现}

}

液晶取表软件:

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/changshang/peixun/267276.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部