?? function.c~
字號:
/*
===================================================
this programe is for 128X160 dots sample, 8080 mode
Crystal 16MHz
MCU Mega16
Compiler CodeVisionAVR
======================================================
*/
#include <mega16.h>
#include <delay.h>
#define uchar unsigned char
#define uint unsigned int
//========write instruction===========================================
void wr_com8080(uchar x)
{
LCD_RS_PORTC&=LCD_RS_CLR;
delay_us(1);
LCD_WR_PORTC|=LCD_WR_SET;
delay_us(1);
LCD_DATA_PORTA=x;
delay_us(1);
LCD_WR_PORTC&=LCD_WR_CLR;
delay_us(1);
LCD_WR_PORTC|=LCD_WR_SET;
delay_us(1);
LCD_DATA_PORTA|=LCD_DATA_SET;
}
//=====write display data==================================================
void wr_data8080(uchar x)
{
LCD_RS_PORTC|=LCD_RS_SET;
delay_us(1);
LCD_WR_PORTC|=LCD_WR_SET;
delay_us(1);
LCD_DATA_PORTA=x;
delay_us(1);
LCD_WR_PORTC&=LCD_WR_CLR;
delay_us(1);
LCD_WR_PORTC|=LCD_WR_SET;
delay_us(1);
LCD_DATA_PORTA|=LCD_DATA_SET;
}
//===========================================================================
void coordinate(uchar col,uchar page)
{
wr_com8080(0x42);
wr_com8080(page+2); //page(row)
wr_com8080(161);
wr_com8080(0x43);
wr_com8080(col); //colomn
wr_com8080(127);
}
//===========================================================================
void setup_registers(void)
{
uchar i;
uchar ini[]={
0x10, //Driver Output Mode Set============================================(10h)
0x23,
0x20, //DC-DC Select 1st Booster Circuit Set Up===========================(20h)
0x33,
0x22, //Bias Set and 2nd Booster Circuit Set Up===========================(22h)
0x22,
0x24, //DCDC Clock Division Set Booster Clock Frequency===================(24h)
0x11,
0x2a, //Contrast Control(1)In normal mode,partial mode0===================(2ah)
0x91,
0x2b, //Contrast Control(2) In partial mode1==============================(2bh)
0x91,
0x2e, //DDRAM Burst Mode OFF/ON(2fh)======================================(2eh)
0x30, //Addressing Mode Set===============================================(30h)
0x00, //
0x32, //Row Vector Mode Set===============================================(32h)
0x00,
0x34, //N-block inversion Set=============================================(34h)
0x89,
0x36, //Frame Frequency Set===============================================(36h)
0x20,
0x40, //Entry Mode Set====================================================(40h)
0x01
};
for(i=0;i<23;i++)
{
wr_com8080(ini[i]);
}
}
//==================================================================================================
void MCU_Initial()
{
DDRA=0xff;
PORTA=0xff;
DDRC=0xFF;
PORTC=0xFF;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -