我的LCD屏用的控制器是UC1608,不知道问题在哪里 就是点不亮 以下是我的源程序 帮我看看问题出现在哪? 还有就是在接收数据的那个地址 我知道怎么设 ,求指教
#include "stm32f10x.h"
#include "lcd.h"
#include "sys.h"
#include "delay.h"
#include "acc_font.h"
#include "led.h"
#define _RD PDout(14) //RD信号
#define _WR   Dout(5) //WR信号
#define D_C   Dout(7) //D/C信号
#define CS   Aout(6) //CS信号
#define _RST   Bout(7) //RST信号
void Delay(__IO u32 nCount) //简单的延时函数
{
for(; nCount != 0; nCount--);
}
void lcd_parallel_out(unsigned char x)
{
GPIO_ResetBits(GPIOE, GPIO_Pin_1); //DB0
GPIO_ResetBits(GPIOD, GPIO_Pin_9); //DB1
GPIO_ResetBits(GPIOE, GPIO_Pin_15); //DB2
GPIO_ResetBits(GPIOE, GPIO_Pin_13); //DB3
GPIO_ResetBits(GPIOE, GPIO_Pin_11); //DB4
GPIO_ResetBits(GPIOE, GPIO_Pin_9); //DB5
GPIO_ResetBits(GPIOE, GPIO_Pin_7); //DB6
GPIO_ResetBits(GPIOD, GPIO_Pin_0); //DB7
if(x&0X01)GPIO_SetBits(GPIOE, GPIO_Pin_1);//DB0
if(x&0X02)GPIO_SetBits(GPIOD, GPIO_Pin_9);//DB1
if(x&0X04)GPIO_SetBits(GPIOE, GPIO_Pin_15);//DB2
if(x&0X08)GPIO_SetBits(GPIOE, GPIO_Pin_13);//DB3
if(x&0X10)GPIO_SetBits(GPIOE, GPIO_Pin_11);//DB4
if(x&0X20)GPIO_SetBits(GPIOE, GPIO_Pin_9);//DB5
if(x&0X40)GPIO_SetBits(GPIOE, GPIO_Pin_7);//DB6
if(x&0X80)GPIO_SetBits(GPIOD, GPIO_Pin_0);//DB7
}
/******* 指令代码写入函数 *******/
void SdCmd(unsigned char Command)
{
Delay(0xFFFFF);
D_C=0; //选择指令通道
CS=1; //选通模块
lcd_parallel_out(Command); //设置指令代码
_WR=0; //写信号有效
_WR=1; //写信号无效
CS=0; //封锁模块
}
/****** 数据写入函数 ********/
void SdData(unsigned char DData)
{
D_C=1; //选择数据通道
// LCD_DATA=DData; //设置数据
lcd_parallel_out(DData);
CS=1; //选通模块
_WR=0; //写信号有效
_WR=1; //写信号无效
CS=0; //封锁模块
}
/******* 数据读取函数 *********/
/*
unsigned char RdData()
{
unsigned char DData;
D_C=1; //选择数据通道
lcd_parallel_out(0XFF);
CS=1; //选通模块
_RD=0; //读操作信号有效
DData=LCD_DATA;
_RD=1; //读操作信号无效
CS=0; //封锁模块
return(DData); //返回数据值
}
*/
void lcd_port_config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE| RCC_APB2Periph_GPIOA , ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 ;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/* 配置相对应的数据线*/
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_0;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_7 | GPIO_Pin_9 | GPIO_Pin_11 |
GPIO_Pin_13 | GPIO_Pin_15;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/*控制端口*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14|GPIO_Pin_7|GPIO_Pin_5;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/*数据模式8080*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_2;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* tft control gpio init */
GPIO_ResetBits(GPIOD, GPIO_Pin_13);
GPIO_SetBits(GPIOD, GPIO_Pin_2);
}
/*** 初始化 *****/
void lcd_init(void)
{
unsigned char ContrastLevel;
//端口配置
lcd_port_config();
_RST=1; //硬件初始化复位
// delay_ms(100);
Delay(0xFFFFF);
_RST=0;
// delay_ms(1);
Delay(0xFFF);
_RST=1;
// delay_ms(800);
Delay(0xFFFFFF); //推迟延时时间
ContrastLevel=0x28; //设置对比度初始化为0x28
SdCmd(0x26); //设置占空比为1/128,温度系数设置为0.1%/C
SdCmd(0x40); //设置显示的起始行=0
SdCmd(0x89); //设置页/列地址自动加1功能
SdCmd(0xaf); //开显示
SdCmd(0x90); //设置区域固定行
SdCmd(0xC4); //设置设置水平映像为逆序,垂直映像为正序,数据排序为D0-D7
SdCmd(0xea); //设置占空比1/12
SdCmd(0x2d); //设置内部LCD电源
SdCmd(0x81); //设置对比度
SdCmd(ContrastLevel); //对比度初始化
}
/*** 清屏函数 *****/
void Clear_lcd()
{
unsigned char i,j;
SdCmd(0xb0); //页地址设置
SdCmd(0x00); //列地址低4位
SdCmd(0x10); //列地址高4位
for(i=0;i<16;i++) //循环写16页
{
for(j=0;j<240;j++) //循环写240单元
{
SdData(0); //数据设置为0
}
}
}
/****** 字符串写入 *********/
void PintASCll(unsigned char x,unsigned char y,unsigned char *pstr)
{
unsigned char j;
u8 addr;
SdCmd(y|0xb0);
SdCmd(x&0x0f);
SdCmd(x>>4|0x10);
while(*pstr>0)
{
addr=*pstr++;
addr=(addr-0x20)*8;
for(j=0;j<6;j++)
{
SdData(ascii_8x16[addr+j]);
}
}
}
|