谁有AVR单片机C语言程序关于lcd显示的程序谢谢啦!!!

 我来答
意法半导体(中国)投资有限公司 2020-01-15
展开全部
单片机(Microcontrollers)是一种集成电路芯片,是采用超大规模集成电路技术把具有数据处理能力的中央处理器CPU、随机存储器RAM、只读存储器ROM、多种I/O口和中断系统、定时器/计数器等功能(可能还包括显示驱动电路、脉宽调制电路、模拟多路转换器、A/D转换器等电路)集成到一块硅片上构成的一个小而完善的微型计算机系统,在工业控制领域广泛应用。从上世纪80年代,由当时的4位、8位单片机,发展到现在的300M的高速单片机。
KGP5358
2011-04-18 · TA获得超过299个赞
知道小有建树答主
回答量:215
采纳率:0%
帮助的人:156万
展开全部
//KGM913A2 DEMO 8-BIT 666MODE 此程序为本公司480*320点阵18-BIT彩色TFT液晶屏的程序
//2010-12-23 BY ERIC
//IC: ILI9481B
//---------------------------------------------------------------------------
#include <avr/io.h>
//#define F_CPU 8000000UL
#define F_CPU 12000000UL
#include <util/delay.h>

#ifndef Delayms
#define Delayms _delay_ms
#endif

#include <avr/pgmspace.h>
#include <stdio.h>
#include <string.h>
#include "font.h"
#include "AT45DB161D.h"

typedef uint16_t UINT, uint;
typedef uint8_t UCHAR, uchar;

#define LCD_RESET PB0
#define LCD_RS PB1
#define LCD_WR PB2

#define KB_NEXT PB3

void W_COM(UCHAR dat);
void W_DATA(UCHAR dat);
void W_RGB(UCHAR dat1,UCHAR dat2,UCHAR dat3);
void BlockWrite(UINT sx, UINT ex, UINT sy, UINT ey);
void ILI9481B_Initial(void);
void Clear(void);
void Full(void);
void Red(void);
void Green(void);
void Blue(void);
void DotsMatrix(UINT sx, UINT ex, UINT sy, UINT ey);
//void Crosstalk_A(void);
//void Crosstalk_B(void);
//void Crosstalk_C(void);
//void Flicker(void);
//void Flicker_SCT(void);
//void GAMMA(void);
void Show(UINT sx, UINT ex, UINT sy, UINT ey, UCHAR dat1,UCHAR dat2,UCHAR dat3);

//#define HexToStr(num,string) sprintf(string, "0x%02X", num)
//---------------------------------------------------------------------------
//char str[10];
int main(void)
{
UCHAR i;

//DDRA = 0xFF;
DDRB = 0xFF;
DDRD = 0xFF;
_NOP();
_NOP();
//PORTA = 0xFF;
PORTB = 0xFF;
PORTD = 0xFF;

Flash_SPI_Init();
Delayms(10);
ReadFlashStatus();
SetPictureSize((uint32_t)480*320);

DDRB &= ~(1<<KB_NEXT);

Delayms(30);
PORTB &= ~(1<<LCD_RESET);
Delayms(50);
PORTB |= (1<<LCD_RESET);
Delayms(100);

ILI9481B_Initial();

for(;;)
{
Full();
while( PINB & (1 << KB_NEXT) );

Clear();
while( PINB & (1 << KB_NEXT) );

Red();
while( PINB & (1 << KB_NEXT) );

Green();
while( PINB & (1 << KB_NEXT) );

Blue();
while( PINB & (1 << KB_NEXT) );

DotsMatrix(0, 319, 0, 479);
while( PINB & (1 << KB_NEXT) );

/* Crosstalk_A();
while( PINB & (1 << KB_NEXT) );

Crosstalk_B();
Delayms(500);
while( PINB & (1 << KB_NEXT) );

Crosstalk_C();
Delayms(500);
while( PINB & (1 << KB_NEXT) );

Flicker();
Delayms(500);
while( PINB & (1 << KB_NEXT) );

Flicker_SCT();
Delayms(500);
while( PINB & (1 << KB_NEXT) );

GAMMA();
//Delayms(500);
//while( PINB & (1 << KB_NEXT) );
*/
for ( i = 0; i < 4; i++ )
{
BlockWrite(0, 319, 0, 479);
ReadFlashUchar3(i, W_RGB);
while( PINB & (1 << KB_NEXT) );
}
}
}
//---------------------------------------------------------------------------
void W_COM(UCHAR dat)
{
PORTB &= ~(1<<LCD_RS);

PORTD = dat;
PORTB &= ~(1<<LCD_WR);
PORTB |= (1<<LCD_WR);

//PORTA = dat;
//PORTB &= ~(1<<LCD_WR);
//PORTB |= (1<<LCD_WR);
}
//---------------------------------------------------------------------------
void W_DATA(UCHAR dat)
{
PORTB |= (1<<LCD_RS);

PORTD = dat;
PORTB &= ~(1<<LCD_WR);
PORTB |= (1<<LCD_WR);

//PORTA = dat;
//PORTB &= ~(1<<LCD_WR);
//PORTB |= (1<<LCD_WR);
}
//---------------------------------------------------------------------------
void W_RGB(uchar dat1,uchar dat2,uchar dat3)
{
PORTB |= (1<<LCD_RS);

PORTD = dat1;
PORTB &= ~(1<<LCD_WR);
PORTB |= (1<<LCD_WR);

PORTD = dat2;
PORTB &= ~(1<<LCD_WR);
PORTB |= (1<<LCD_WR);

PORTD = dat3;
PORTB &= ~(1<<LCD_WR);
PORTB |= (1<<LCD_WR);
}

//---------------------------------------------------------------------------
void BlockWrite(UINT sx, UINT ex, UINT sy, UINT ey)
{
W_COM(0x2A);
W_DATA(sx>>8);
W_DATA(sx);
W_DATA(ex>>8);
W_DATA(ex);

W_COM(0x2B);
W_DATA(sy>>8);
W_DATA(sy);
W_DATA(ey>>8);
W_DATA(ey);

W_COM(0x2c);
}
//---------------------------------------------------------------------------
void Clear(void)
{
Show(0, 319, 0, 479, 0X00,0X00,0X00);
}
//---------------------------------------------------------------------------
void Full(void)
{
Show(0, 319, 0, 479, 0xFF,0XFF,0XFF);
}
//---------------------------------------------------------------------------
void Red(void)
{
Show(0, 319, 0, 479, 0xFF,0X00,0X00);
}
//---------------------------------------------------------------------------
void Green(void)
{
Show(0, 319, 0, 479, 0x00,0XFF,0X00);
}
//---------------------------------------------------------------------------
void Blue(void)
{
Show(0, 319, 0, 479, 0x00,0X00,0XFF);
}
//---------------------------------------------------------------------------
void DotsMatrix(UINT sx, UINT ex, UINT sy, UINT ey)
{
UINT x, y, i, j;
BlockWrite(sx, ex, sy, ey);

x = ex - sx;
y = ey - sy;

for ( i = 0; i <= y; i++ )
for ( j = 0; j <= x; j++ )
{
if ( (i + j) & 1 )
{
W_RGB(0xFF,0XFF,0XFF);
}
else
{
W_RGB(0x00,0X00,0X00);
}
}
}
//---------------------------------------------------------------------------
/*void Crosstalk_A(void)
{
Show(0, 239, 0, 399, 0XEF5D);
Show(79, 159, 0, 140, 0x0000);
Show(79, 159, 262, 400, 0x0000);
}
//---------------------------------------------------------------------------
void Crosstalk_B(void)
{
Show(79, 159, 0, 140, 0XEF5D);
Show(79, 159, 262, 400, 0XEF5D);
}
//---------------------------------------------------------------------------
void Crosstalk_C(void)
{
Show(0, 79, 133, 265, 0);
Show(159, 239, 133, 265, 0);
}
//---------------------------------------------------------------------------
void Flicker(void)
{
UINT i, j;

BlockWrite(0, 239, 0, 399);

for ( i = 0; i <= 399; i++ )
{
if(i & 1)
for ( j = 0; j <= 239; j++ )
W_RGB(0xFFFF);
else
for ( j = 0; j <= 239; j++ )
W_RGB(0x0000);
}
}
//---------------------------------------------------------------------------
void Flicker_SCT(void)
{
UINT i, j;
BlockWrite(0, 239, 0, 399);

for ( i = 0; i <= 399; i++ )
for ( j = 0; j <= 239; j++ )
{
if(i%3)
W_RGB(0X7BEF);
else
W_RGB(0);
}
}
//---------------------------------------------------------------------------
void GAMMA(void)
{
Show(0, 239, 0, 399, 0x0000);
ShowString(200, 380, "000");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0X1082);
ShowString(200, 380, "016");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0X2104);
ShowString(200, 380, "032");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0X3186);
ShowString(200, 380, "048");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0X4208);
ShowString(200, 380, "064");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0X528A);
ShowString(200, 380, "080");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0X630C);
ShowString(200, 380, "096");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0X738E);
ShowString(200, 380, "112");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0X8410);
ShowString(200, 380, "128");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0X9492);
ShowString(200, 380, "144");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0XA514);
ShowString(200, 380, "160");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0XB596);
ShowString(200, 380, "176");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0XC618);
ShowString(200, 380, "192");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0XD69A);
ShowString(200, 380, "208");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0XE71C);
ShowString(200, 380, "224");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0XF79E);
ShowString(200, 380, "240");Delayms(500);while( PINB & (1 << KB_NEXT) );
Show(0x0000, 0x00EF, 0x0000, 0x018F, 0XFFFF);
ShowString(200, 380, "255");Delayms(500);while( PINB & (1 << KB_NEXT) );
}
//---------------------------------------------------------------------------*/
void Show(UINT sx, UINT ex, UINT sy, UINT ey, UCHAR dat1, UCHAR dat2, UCHAR dat3)
{
UINT x, y, i, j;
BlockWrite(sx, ex, sy, ey);

x = ex - sx;
y = ey - sy;

for ( i = 0; i <= y; i++ )
for ( j = 0; j <= x; j++ )
{
W_RGB(dat1,dat2,dat3);
}
}
//---------------------------------------------------------------------------
void ILI9481B_Initial(void)
{
W_COM(0X20);
W_COM(0X11);
Delayms(20);
W_COM(0XD0); //
W_DATA(0X07); // VC[2:0]
W_DATA(0X41); // PON,BT[2:0]
W_DATA(0X16); // VCIRE,VRH[3:0]=1A

W_COM(0XD1);
W_DATA(0X00); // SELVCM
W_DATA(0X2C); // VCM[5:0]0X2C;30
W_DATA(0X13); // VDV[4:0]0X11;13;13crosstalk较重

W_COM(0XD2);
W_DATA(0X01); // AP0[2:0]0X03CROSSTALK好点
W_DATA(0X11); // DC10[2:0],DC00[2:0]

W_COM(0XC0); //****** *******
W_DATA(0X10); // REV & SM & GS
W_DATA(0X3B); // NL[5:0]
W_DATA(0X00); // SCN[6:0]
W_DATA(0X02); // NDL , PTS[2:0]
W_DATA(0X11); // PTG , ISC[3:0]

W_COM(0XC1);
W_DATA(0X10);
W_DATA(0X10); //LINE TIMMING增大改善CROSSTALK>14会闪烁
W_DATA(0X88);

W_COM(0XC5); // Frame rate
W_DATA(0X03);

W_COM(0XC8); // Gamma Setting
W_DATA(0X00); // KP1[2:0],KP0[2:0]
W_DATA(0X66); // KP3[2:0],KP2[2:0]
W_DATA(0X15); // KP5[2:0],KP4[2:0]
W_DATA(0X24); // RP1[2:0],RP0[2:0]
W_DATA(0X00); // VRP0[3:0]
W_DATA(0X08); // VRP1[4:0]
W_DATA(0X26); // KN1[2:0],KN0[2:0]
W_DATA(0X11); // KN3[2:0],KN2[2:0]
W_DATA(0X77); // KN5[2:0],KN4[2:0]
W_DATA(0X42); // RN1[2:0],RN0[2:0]
W_DATA(0X08); // VRN0[3:0]
W_DATA(0X00); // VRN1[4:0]

W_COM(0XE4);
W_DATA(0XA0);

W_COM(0XF0);
W_DATA(0X01);

W_COM(0XF3);
W_DATA(0X30);
W_DATA(0X0A);

W_COM(0XF7);
W_DATA(0X80);

W_COM(0X36); // Set_address_mode
W_DATA(0X0A); // Bit3: RGB/BGR
Delayms(120);
W_COM(0X3A);
W_DATA(0X66);
W_COM(0X29);
}
意法半导体(中国)投资有限公司
2021-01-14 广告
1、不是的,STC单片机全面兼容MCS-51单片机,可以用一般的编程器编程,但ISP功能更方便实用。 2、实验板的串口就是ISP下载用的吧。 4、汇编语言不一定要在keil里学,一般的教程都可以学。keil只是一个编译程序。因为keil编译... 点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式