/*************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
#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循环
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); //开显示 } } 液晶取表软件:
上一篇:ATMEGA8A 单片机I/O口模拟串口
下一篇:AVR简单的串口通信程序
推荐阅读最新更新时间:2024-03-16 15:08