C2000串行驱动 LCD12864出现了问题,很急很迫切。芯片是F28027
[复制链接]
1 芯积分
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
char table0[]="电气工程学院";
char table1[]="测控0901";
char table2[]="李永超";
char table3[]="200948770102";
//******************delay*************************//
void delay(int count)
{
while(count--);
}
//******************GPIO configure****************//
void Gpio_Init(void)
{
EALLOW;
GpioCtrlRegs.GPAMUX1.all = 0x00000000; // All GPIO//MUX寄存器是多路复用寄存器,低电平代表不复用,使用的时候要进行保护
GpioCtrlRegs.GPAMUX2.all = 0x00000000; // All GPIO
GpioCtrlRegs.GPBMUX1.all = 0x00000000; // All GPIO
GpioCtrlRegs.GPADIR.all = 0xFFFFFFFF; // All outputs
GpioCtrlRegs.GPBDIR.all = 0x0000000F; // All outputs
EDIS;
}
//******************Datas sending function*************//
void Sendbyte(unsigned char data1)
{
unsigned int i;
for(i=0;i<8;i++)
{
GpioDataRegs.GPADAT.bit.GPIO7=0; //GPIO0 is CLK
if(data1&0x80)
GpioDataRegs.GPADAT.bit.GPIO6=1; //GPIO1 is data output pin
else
GpioDataRegs.GPADAT.bit.GPIO6=0;
GpioDataRegs.GPADAT.bit.GPIO7=1;
data1=data1<<1;
delay(0xff);
}
}
//******************Command sending function*************//
void write_com(unsigned char com)
{
GpioDataRegs.GPADAT.bit.GPIO5=1;
Sendbyte(0xf8);
Sendbyte(com&0xf0);
Sendbyte((com&0x0f)<<4);
GpioDataRegs.GPADAT.bit.GPIO5=0;
delay(0xff);
}
//******************Display data sending function*************//
void write_data(unsigned char data)
{
GpioDataRegs.GPADAT.bit.GPIO5=1;
Sendbyte(0xfa); //That is to say
Sendbyte(data&0xf0);
Sendbyte((data&0x0f)<<4);
GpioDataRegs.GPADAT.bit.GPIO5=0;
delay(0xff);
}
void LCD_Init()
{
write_com(0x01);
write_com(0x30);
write_com(0x0c);
write_com(0x06);
write_com(0x02);
}
void main(void)
{
unsigned int n;
InitSysCtrl();
Gpio_Init();
DINT; //屏蔽中断
InitPieCtrl(); //初始化中断控制寄存器
IER = 0x0000; //中断使能寄存器,某一位是1表示使能中断
IFR = 0x0000; //中断标志寄存器,某一位是1表示产生中断标志
InitPieVectTable();//初始化中断向量表,把向量表复制到指定RAM段,防止非法中断的产生
LCD_Init();
//************************The first line**********************//
write_com(0x80);
write_data(0x0b);
write_data(0x0b);
for(n=0;n<12;n++)
{
write_data(table0[n]);
delay(0xff);
}
write_data(0x0b);
write_data(0x0b);
//************************The second line**********************//
write_com(0x90);
for(n=0;n<8;n++)
{
write_data(table1[n]);
delay(0xff);
}
//************************The third line**********************//
write_com(0x88);
write_data(0x03);
write_data(0x03);
for(n=0;n<6;n++)
{
write_data(table2[n]);
delay(0xff);
}
write_data(0x03);
write_data(0x03);
//************************The fourth line**********************//
write_com(0x98);
for(n=0;n<12;n++)
{
write_data(table3[n]);
delay(0xff);
}
while(1);
}
//=========================================================================
// No more.
//=========================================================================
[ 本帖最后由 woshilee 于 2013-7-16 10:09 编辑 ]
我来回答