NOKIA3300彩色液晶測試程序
/*************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_da
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_da
lcd_da
lcd_command (CASET);
lcd_da
lcd_da
lcd_command (RAMWR);
for (num=0;num<12544;num++)
lcd_da
while(1);
} //while循環(huán)
return (0);
}
void init_mcu (void) //初始化
{
DDRB=0xff;
PORTB=0xff;
_delay_us(1);
}
void lcd_da
{
LCD_CS_L;
LCD_CLK_L;
LCD_DIN_H; //數據
LCD_CLK_H;
SPCR=0x50;
SPDR=da
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_da lcd_da lcd_da lcd_da lcd_command (COMSCN); //上下半圖象掃描順序 lcd_da lcd_command (OSCON); lcd_command (SLPOUT); lcd_command (VOLCTR); lcd_da lcd_da lcd_command (PWRCTR); lcd_da lcd_command (DISINV); //顏色順序 lcd_command (PTLOUT); lcd_command (DATCTL); lcd_da lcd_da lcd_da lcd_command (RGBSET8); //調色板設置 lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_da lcd_command (DISON); //開顯示} } 液晶取表軟件:
評論