在做STM32F103VC驱动ST7565R时一直都点不亮LCD,不知道为什么,恳请各位大侠帮助。。。。
我的LCD电路图纸(见图片)
程序代码如下:
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"
#define LCD_CS0 GPIO_ResetBits(GPIOE , GPIO_Pin_1);
#define LCD_CS1 GPIO_SetBits(GPIOE , GPIO_Pin_1);
#define lCD_RES0 GPIO_ResetBits(GPIOE , GPIO_Pin_0);
#define lCD_RES1 GPIO_SetBits(GPIOE , GPIO_Pin_0);
#define LCD_RS0 GPIO_ResetBits(GPIOB , GPIO_Pin_0);
#define LCD_RS1 GPIO_SetBits(GPIOB , GPIO_Pin_0);
#define LCD_WR0 GPIO_ResetBits(GPIOB , GPIO_Pin_1);
#define LCD_WR1 GPIO_SetBits(GPIOB , GPIO_Pin_1);
#define LCD_RD0 GPIO_ResetBits(GPIOB , GPIO_Pin_2);
#define LCD_RD1 GPIO_SetBits(GPIOB , GPIO_Pin_2);
/* Private functions ---------------------------------------------------------*/
void GPIO_Configuration(void);
void LCD_Initial(void);
void LCD_TransferCommand(int DATA);
void LCD_TransferData(int DATA);
void LCD_ClearScreen(void);
void LCD_Address(unsigned char PAGE, unsigned char COLUM);
void LCD_TestDisplay(unsigned char DATA1,unsigned char DATA2);
/*******************************************************************************
* Function Name : Delay
* Description : Delay Time
* Input : - nCount: Delay Time
* Output : None
* Return : None
* Attention : None
*******************************************************************************/
void Delay (uint32_t delay)
{
unsigned int opp=0, p=0;
for(p=0;p<delay;p++)
{
opp=2860;
do opp--;
while(opp>0);
}
}
/*******************************************************************************
* Function Name : main
* Description : Main Programme
* Input : None
* Output : None
* Return : None
* Attention : None
*******************************************************************************/
int main(void)
{
GPIO_Configuration();
LCD_Initial();
/* Infinite loop */
while (1)
{
LCD_TestDisplay(0x55,0xaa);
}
}
/*******************************************************************************
* Function Name : GPIO_Configuration
* Description : Configure GPIO Pin
* Input : None
* Output : None
* Return : None
* Attention : None
*******************************************************************************/
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOE, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_3 | GPIO_Pin_4| GPIO_Pin_5
| GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12
| GPIO_Pin_13 | GPIO_Pin_14| GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5| GPIO_Pin_6;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOE, &GPIO_InitStructure);
}
void LCD_TransferCommand(int DATA)
{//D_ReadBusy();//忙状态检查
LCD_CS0;
LCD_RS0;
LCD_RD0;
LCD_WR0;
DATA = (DATA <<8)&0xff00;
DATA = (GPIO_ReadOutputData(GPIOB)&0xff)&DATA;
GPIO_Write(GPIOB, DATA);
LCD_RD1;
LCD_CS1;
LCD_RD0;
}
void LCD_TransferData(int DATA)
{//D_ReadBusy();//忙状态检查
LCD_CS0;
LCD_RS1;
LCD_RD0;
LCD_WR0;
DATA = (DATA <<8)&0xff00;
DATA = (GPIO_ReadOutputData(GPIOB)&0xff)&DATA;
GPIO_Write(GPIOB, DATA);
LCD_RD1;
LCD_CS1;
LCD_RD0;
}
void LCD_ClearScreen(void)
{
unsigned char i,j;
LCD_CS0;
for(i=0;i<9;i++)
{
LCD_Address(i+1,1);
for(j=0;j<132;j++)
{
LCD_TransferData(0x00);
}
}
LCD_CS1;
}
void LCD_TestDisplay(unsigned char DATA1,unsigned char DATA2)
{
unsigned char i,j;
for(j=0;j<8;j++)
{
LCD_CS0;
LCD_Address(j+1,0);
for(i=0;i<128;i++)
{
LCD_TransferData(DATA1);
LCD_TransferData(DATA2);
}
}
}
void LCD_Address(unsigned char PAGE, unsigned char COLUMN)
{
LCD_CS0;
COLUMN = COLUMN;
PAGE = PAGE -1;
LCD_TransferCommand(0xb0+PAGE);
LCD_TransferCommand(((COLUMN>>4)&0x0f)+0x10);
LCD_TransferCommand(COLUMN&0x0f);
}
void LCD_Initial(void)
{
LCD_CS0;
lCD_RES0;//low volt reset
Delay(100);
lCD_RES1;//reset done
Delay(20);
LCD_TransferCommand(0xe2);//software reset
Delay(50);
LCD_TransferCommand(0x2c);//improve volt step1
Delay(50);
LCD_TransferCommand(0x2e);//improve volt step2
Delay(50);
LCD_TransferCommand(0x2f);//improve volt step3
Delay(50);
LCD_TransferCommand(0x24);//粗调对比度,范围0x20~0x27
LCD_TransferCommand(0x81);//微调对比度
LCD_TransferCommand(0x2c);//0x1a,微调对比度值,可设置范围0x00~0x3f
LCD_TransferCommand(0xa2);//1/9偏压比
LCD_TransferCommand(0xc8);//行扫描顺序,从上到下
LCD_TransferCommand(0xa0);//列扫描顺寻,从左到右
LCD_TransferCommand(0x60);//起始行,第一行开始
LCD_TransferCommand(0xaf);//开显示
Delay(10);
LCD_CS1;
}
帮忙分析一下,不知道问题出在哪里。。。。
救命啊。。。。
谢谢!
一周热门 更多>