我使用dispic30f驱动320240的单色怎么也不显示,没辙了请高手看看 怎么回事就是不显示呢?我以为是时序可改了半天了
/*
1.程序建立:2016062130915 版本号V1.0CS CS测试版
2.单片机动作速率为HS/2*8。两分频八倍频,为20M/秒。
3.控制字设置:C712,003F,8733,310F,330F,0007,C003。
*/
//********************头文件声明************************
#include "p30f6014A.h"
//********************宏、常数声明**********************
#define uchar unsigned char
#define uint unsigned int //无符号短整型
#define ulint unsigned long int //无符号长整型
#define ullint unsigned long long //无符号长长整型
#define lcd_cs1 _LATD8
#define lcd_rs _LATD9
#define lcd_rd _LATD11
#define lcd_wr _LATD10
#define lcd_rst _LATD12
#define lcd_int _LATF5
#define lcd_busy _LATF4
#define WLCR 0x00
#define MISC 0x01
#define ADSR 0x03
#define INTR 0x0F
#define WCCR 0x10
#define CHWI 0x11 //new(have change)
#define MAMR 0x12
#define AWRR 0x20
#define DWWR 0x21
#define AWBR 0x30
#define DWHR 0x31 //new(have change)
#define AWLR 0x40
#define AWTR 0x50
#define CURX 0x60 //new(have change)
#define BGSG 0x61
#define EDSG 0x62 //new
#define CURY 0x70 //new(have change)
#define BGCM 0x71
#define EDCM 0x72
#define BTMR 0x80
#define ITCR 0x90 //new(have change)
#define KSCR1 0xA0
#define KSCR2 0xA1
#define KSDR0 0xA2 //new(have change)
#define KSDR1 0xA3
#define KSDR2 0xA4
#define MWCR 0xB0 //new(have change)
#define MRCR 0xB1 //new
#define TPCR 0xC0
#define TPXR 0xC1
#define TPYR 0xC2
#define TPZR 0xC3
#define PCR 0xD0 //new(have change)
#define PDCR 0xD1 //new
#define PNTR 0xE0
#define FNCR 0xF0
#define FVHT 0xF1
uint temp; //lcd使用临时保存
//*********************************
void dspic_start(void)
{
PORTD=0;LATD=0;TRISD=0x0000; //为输出
}
//*************************************
void delay_nms(uint n)
{
uint i,j;
for(i=n;i>0;i--)
{
for(j=125;j>0;j--)
{
}
}
}
//*************************************
void lcd_erst(void)
{
lcd_rst=1;
delay_nms(50);
lcd_cs1=1;
lcd_rs=1;
lcd_rd=1;
lcd_wr=1;
lcd_rst=0;
delay_nms(20);
lcd_rst=1;
delay_nms(20);
}
//*************************************
void lcd_cmdwrite(uchar cmdaddr)
{
uint a;
//8080
lcd_cs1=0;
lcd_rs=1;
lcd_rd=1;
a=PORTD&0XFF00;
PORTD=cmdaddr|a;
lcd_wr=0;
lcd_wr=1;
lcd_cs1=1;
//6800
// lcd_cs1=0;
// lcd_rs=1;
// lcd_wr=0;
// PORTD=PORTD&0XFF00;
// PORTD=cmdaddr|PORTD;
// lcd_rd=1;
// lcd_rd=0;
// lcd_cs1=1;
}
//*************************************
void lcd_datawrite(uchar wrdata)
{
uint b;
//8080
delay_nms(500);
lcd_cs1=0;
lcd_rs=0;
lcd_rd=1;
b=PORTD&0XFF00;
PORTD=wrdata|b;
lcd_wr=0;
lcd_wr=1;
lcd_cs1=1;
// //6800
// lcd_cs1=0;
// lcd_rs=0;
// lcd_wr=0;
// PORTD=PORTD&0XFF00;
// PORTD=wrdata|PORTD;
// lcd_rd=1;
// lcd_rd=0;
// lcd_cs1=1;
}
//*************************************
void lcd_clear(void)
{
lcd_cmdwrite(0x00);
lcd_datawrite(0x04);//绘图模式
lcd_cmdwrite(0xe0);
lcd_datawrite(0x00);
lcd_cmdwrite(0xf0);
lcd_datawrite(0xa8);
delay_nms(10);
}
//*************************************
void lcd_all(void)
{
lcd_cmdwrite(0x00);
lcd_datawrite(0x04);//绘图模式
lcd_cmdwrite(0xe0);
lcd_datawrite(0xff);
lcd_cmdwrite(0xf0);
lcd_datawrite(0xa8);
delay_nms(10);
}
//*************************************
void lcd_start(void)//配置LCD
{
lcd_cmdwrite(WLCR) ;
lcd_datawrite(0X04); //[00H] , LCD=ON
lcd_cmdwrite(MISC); //[01H] , Default --> 0x00
lcd_datawrite(0x04);
lcd_cmdwrite(ADSR); //[03H] , Default --> 0x00
lcd_datawrite(0x00);
lcd_cmdwrite(INTR); //[0FH] , Default --> 0x00
lcd_datawrite(0x00);
lcd_cmdwrite(WCCR); //[10H] , Default --> 0x00
lcd_datawrite(0x04);
lcd_cmdwrite(CHWI); //[11H] , Default --> 0x00
lcd_datawrite(0xf0);
lcd_cmdwrite(MAMR); //[12H] , Default --> 0x11
lcd_datawrite(0x11);
lcd_cmdwrite(AWRR); //[20H] , Default --> 0x27
lcd_datawrite(0x27);
lcd_cmdwrite(DWWR); //[21H] , Default --> 0x27
lcd_datawrite(0x27);
lcd_cmdwrite(AWBR); //[30H] , Default --> 0xEF
lcd_datawrite(0xef);
lcd_cmdwrite(DWHR); //[31H] , Default --> 0xEF
lcd_datawrite(0xef);
lcd_cmdwrite(AWLR); //[40H] , Default --> 0x00
lcd_datawrite(0x00);
lcd_cmdwrite(AWTR); //[50H] , Default --> 0x00
lcd_datawrite(0x00);
lcd_cmdwrite(CURX); //[60H] , Default --> 0x00
lcd_datawrite(0x00);
lcd_cmdwrite(BGSG); //[61H] , Default --> 0x00
lcd_datawrite(0x00);
lcd_cmdwrite(EDSG); //[62H] , Default --> 0x00
lcd_datawrite(0x00);
lcd_cmdwrite(CURY); //[70H] , Default --> 0x00
lcd_datawrite(0x00);
lcd_cmdwrite(BGCM); //[71H] , Default --> 0x00
lcd_datawrite(0x00);
lcd_cmdwrite(EDCM); //[72H] , Default --> 0x00
lcd_datawrite(0x00);
lcd_cmdwrite(BTMR); //[80H] , Default --> 0x00
lcd_datawrite(0x00);
lcd_cmdwrite(ITCR); //[90H] , Default --> 0x00 对比度
lcd_datawrite(0x00);
lcd_cmdwrite(PNTR); //[E0H] , Default --> 0x00
lcd_datawrite(0x00);
lcd_cmdwrite(FNCR); //[F0H] , Default --> 0x00
lcd_datawrite(0x00);
lcd_cmdwrite(FVHT); //[F1H] , Default --> 0x00
lcd_datawrite(0x00);
//lcd_clear();
lcd_all();
}
//**********************************
int main(void)
{
dspic_start();
lcd_erst();//LCD REST
lcd_start();//配置LCD
//lcd_clear();
lcd_cmdwrite(0xb0);
lcd_datawrite(0xff);
while(1);
} |