LPC2136 SSP 接口驱动 NOKIA 6610 LCD 成功 发帖祝贺
http://cache.amobbs.com/bbs_upload782111/files_28/ourdev_541615.gif(原文件名:电路图.gif)
http://cache.amobbs.com/bbs_upload782111/files_28/ourdev_541616.gif
(原文件名:NOKIA 6610 LCD 显示效果图.gif)
#include "LPC213X.H"
#include "delay.h"
#define SCK1 (2<<2)
#define MOSI1 (2<<6)
#define PWM (1<<21)
#define CS (1<<20)
#define RST (1<<18)
//GPIO功能初始化
void GPIO_Init(void)
{
//PCONP外设功率控制寄存器,复位值为1,默认打开所有模块
PINSEL0=0x00000000;
PINSEL1=SCK1|MOSI1;
IOSET0|=(PWM|CS|RST);
IODIR0|=(PWM|CS|RST);
IOCLR0|=RST;
delay(10000);
IOSET0|=RST;
delay(10000);
}
void SPI_Init(void)
{
//SCK1=PCLK/(CPSDVSR*(SCR+1))=60MHz/(2*(59+1))=0.5MHz,常态为0,第1个时钟跳变沿捕获串行数据,上升沿有效,SPI,9Bit
SSPCR0=0x3b08;
//CPSDVSR=2分频(2~254)
SSPCPSR=2;
//SSP主机使能
SSPCR1=0x02;
}
unsigned int SSP_RD(void)
{
SSPDR=0xff;
while((SSPSR&0x01)!=0x01);
return SSPDR;
}
void SSP_WR(unsigned int data)
{
SSPDR=data;
while((SSPSR&0x01)!=0x01);
data=SSPDR;
}
void LCD_WR_DATA(unsigned int data)
{
SSP_WR(0x100|data);
}
void LCD_WR_CMD(unsigned int cmd)
{
SSP_WR(0x0ff&cmd);
}
void LCD_Init(void)
{
unsigned int i;
GPIO_Init();
SPI_Init();
//颜色模式
IOCLR0|=CS;
LCD_WR_CMD(0x3a);
LCD_WR_DATA(0x05);//RGB565
IOSET0|=CS;
//
IOCLR0|=CS;
//Sleep_OUT
LCD_WR_CMD(0x11);
//display on
LCD_WR_CMD(0x29);
//booster voltage on
LCD_WR_CMD(0x03);
//all pixel on
LCD_WR_CMD(0x23);
IOSET0|=CS;
//设置显示区大小
IOCLR0|=CS;
LCD_WR_CMD(0x2A);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x83);
LCD_WR_CMD(0x2B);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x83);
IOSET0|=CS;
//显示模式,正常
IOCLR0|=CS;
LCD_WR_CMD(0x13);
IOSET0|=CS;
//设置显示区大小
IOCLR0|=CS;
LCD_WR_CMD(0x2A);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x83);
LCD_WR_CMD(0x2B);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x83);
IOSET0|=CS;
//显示数据
IOCLR0|=CS;
LCD_WR_CMD(0x2C);
for(i=0;i<132*44;i++)
{
LCD_WR_DATA(0xf8);
LCD_WR_DATA(0x00);
}
for(i=0;i<132*44;i++)
{
LCD_WR_DATA(0x07);
LCD_WR_DATA(0xe0);
}
for(i=0;i<132*44;i++)
{
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x1f);
}
IOSET0|=CS;
} LZ好人啊 unsigned int SSP_RD(void)
{
SSPDR=0xff;
while((SSPSR&0x01)!=0x01);
return SSPDR;
}
void SSP_WR(unsigned int data)
{
SSPDR=data;
while((SSPSR&0x01)!=0x01);
data=SSPDR;
}
这两个怎么一样了呀? 愚昧了{:shy:} 高手太多,没人顶 祝贺楼主 {:handshake:}{:handshake:}{:handshake:} 支持楼主
页:
[1]