新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > NOKIA3300彩色液晶測試程序

NOKIA3300彩色液晶測試程序

作者: 時間:2016-11-18 來源:網絡 收藏

本文引用地址:http://m.butianyuan.cn/article/201611/316048.htm

/*************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循環(huán)

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); //開顯示}

}

液晶取表軟件:



評論


技術專區(qū)

關閉