傻逼了,用28335驱动一个1602,竟然没搞定。
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
void LCD_Init(void)
{
LCD_delay(1000);
LCD_delay(1000);
LCD_delay(1000);
LCD_Send(0,0x30); //selcete lcd data bus in 8-bit, display in two lines,display in 5*10 way
LCD_delay(1000);
LCD_Send(0,0x30);
LCD_delay(1000);
LCD_Send(0,0x30);
LCD_delay(1000);
LCD_Send(0,0x38);
LCD_delay(1000);
LCD_Send(0,0x08);
LCD_delay(1000);
LCD_Send(0,0x01); //set cours move direction right, disable display move
LCD_delay(1000);
LCD_Send(0,0x06);
LCD_delay(1000);
LCD_Send(1,0x41);
}
//====================================================
//name : void LCD_Send(uint16 di,LCD_Data data)
//func : send data or instruction to lcd displayer
//di:H send data di:L send instruction
//====================================================
void LCD_Send(Uint16 di,Uint32 data)
{
LCD_E_CLR;
LCD_delay(10);
LCD_RW_CLR;
if(di==0)
LCD_CS_CLR;
else
LCD_CS_SET;
GpioDataRegs.GPBDAT.all = data<<8;
LCD_delay(20);
LCD_E_SET;
LCD_delay(40);
LCD_E_CLR;
LCD_delay(20);
GpioDataRegs.GPBDAT.bit.GPIO40 = 0;
GpioDataRegs.GPBDAT.bit.GPIO41 = 0;
GpioDataRegs.GPBDAT.bit.GPIO42 = 0;
GpioDataRegs.GPBDAT.bit.GPIO43 = 0;
GpioDataRegs.GPBDAT.bit.GPIO44 = 0;
GpioDataRegs.GPBDAT.bit.GPIO45 = 0;
GpioDataRegs.GPBDAT.bit.GPIO46 = 0;
GpioDataRegs.GPBDAT.bit.GPIO47 = 0;
LCD_delay(1000);
}
void LCD_delay(Uint16 count)
{
Uint16 i=15;
for(;count>0;count--)
{
for(;i>0;i--);
}
}
上面是lcd.c
下面是lcd.h
#ifndef LCD_H
#define LCD_H
#define LCD_E_SET GpioDataRegs.GPCDAT.bit.GPIO64=1
#define LCD_RW_SET GpioDataRegs.GPCDAT.bit.GPIO65=1
#define LCD_CS_SET GpioDataRegs.GPCDAT.bit.GPIO66=1
#define LCD_RST_SET GpioDataRegs.GPCDAT.bit.GPIO67=1
#define LCD_E_CLR GpioDataRegs.GPCDAT.bit.GPIO64=0
#define LCD_RW_CLR GpioDataRegs.GPCDAT.bit.GPIO65=0
#define LCD_CS_CLR GpioDataRegs.GPCDAT.bit.GPIO66=0
#define LCD_RST_CLR GpioDataRegs.GPCDAT.bit.GPIO67=0
#endif
此帖出自
小平头技术问答
一周热门 更多>