我用st7565p驱动12864 想显示“液晶模块卖场”这四个字 但是现在这四个字显示不完整 有可能是什么原因造成 接线应该没接错 软件看了很久看不出是什么原因
lcd.c文件如下
#include "lcd.h"
#include "
STM32f10x.h"
#include "delay.h"
#include "led.h"
/****************************LCD_RESet IC for start****************************/
void LCD_RESet(void)
{
// IE = 0x00;
LCD_RES=0;
delay_ms(50);
LCD_RES=1;
delay_ms(50);
}
/*******************************write Data to IC**************************/
void w_dat(unsigned char dat)
{
GPIOD->ODR&=0X00FF;
GPIOD->ODR|=(dat<<8);
__NOP();
__NOP();
__NOP();
__NOP();
LCD_RS=1;
LCD_RW=0;
LCD_Read=1;
__NOP();
__NOP();
__NOP();
__NOP();
LCD_CS=1;
__NOP();
__NOP();
__NOP();
__NOP();
LCD_CS=0;
}
/******************************write Command to IC***********************/
void w_cmd(unsigned char cmd)
{
GPIOD->ODR&=0X00FF;
GPIOD->ODR|=(cmd <<8);
__NOP();
__NOP();
__NOP();
__NOP();
LCD_RS=0;
LCD_RW=0;
LCD_Read=1;
__NOP();
__NOP();
__NOP();
__NOP();
LCD_CS=1;
__NOP();
LCD_CS=0;
}
/***************************display picture *****************************/
void Display(unsigned char *p)
{
unsigned char page,column;
for(page=0xB7;page>=0xB0;page--)
{
w_cmd(page); //set page addLCD_RESs
w_cmd(0x10); //set Column addLCD_RESs MSB
w_cmd(0x00); //set column addLCD_RESs LSB
for(column=0;column<128;column++)
{
w_dat(*p++);
}
}
}
void Display_fill(unsigned char fill)
{
unsigned char page,column;
for(page=0xB7;page>=0xB0;page--)
{
w_cmd(page); //set page addLCD_RESs
w_cmd(0x10); //set Column addLCD_RESs MSB
w_cmd(0x00); //set column addLCD_RESs LSB
for(column=0;column<131;column++)
{
w_dat(fill);
}
}
}
void Grid_white(void)
{
unsigned char page,column;
for(page=0xB7;page>=0xB0;page--)
{
w_cmd(page);
w_cmd(0x10);
w_cmd(0x00);
for(column=0;column<65;column++)
{
w_dat(0xFF);
w_dat(0x00);
}
}
}
void Grid_Black(void)
{
unsigned char page,column;
for(page=0xB7;page>=0xB0;page--)
{
w_cmd(page);
w_cmd(0x10);
w_cmd(0x00);
for(column=0;column<65;column++)
{
w_dat(0x00);
w_dat(0xFF);
}
}
}
void Grid_Line1(void)
{
unsigned char page,column;
for(page=0xB7;page>=0xB0;page--)
{
w_cmd(page);
w_cmd(0x10);
w_cmd(0x00);
for(column=0;column<131;column++)
{
w_dat(0xAA);
}
}
}
void Grid_Line2(void)
{
unsigned char page,column;
for(page=0xB7;page>=0xB0;page--)
{
w_cmd(page);
w_cmd(0x10);
w_cmd(0x00);
for(column=0;column<131;column++)
{
w_dat(0x55);
}
}
}
void Lcd_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //ʹÄÜPA¶Ë¿ÚʱÖÓ
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE); //ʹÄÜPD¶Ë¿ÚʱÖÓ
GPIO_InitStructure.GPIO_Pin = Data;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
LCD_CS = 0;
// GPIOD->ODR&=0X00FF;
// GPIOD->ODR|=(0XFF<<8);
LCD_RESet();
// w_cmd(0xA2); //LCD Bias selec
tion(1/65 Duty,1/9Bias)
// w_cmd(0xA0); //ADC selection(SEG0->SEG128) ÁÐɨÃè ´Ó×óµ½ÓÒ
// w_cmd(0xC0); //SHL selection(COM0->COM64) ҳɨÃè ´Óϵ½ÉÏ
// w_cmd(0x26); //Regulator LCD_RESistor Selection
// delay_ms(5);
// w_cmd(0x81); //Electronic Volume µçÁ¿
// w_cmd(0x8); //Reference Register selection Vo=(1+Rb/Ra)(1+a)*2.1=10
// w_cmd(VC_ON); //Power Control(Vc=1;Vr=0;Vf=0)
// delay_ms(10);
// w_cmd(VC_ON|VR_ON);
// delay_ms(10);
// w_cmd(VC_ON|VR_ON|VF_ON);
// delay_ms(10);
// w_cmd(0xF8);
// w_cmd(0x00);
// delay_ms(5);
// w_cmd(0xAF); //Display on
w_cmd(0xE2);
delay_ms(5);
w_cmd(0x2c); /*Éýѹ²½¾Û1*/
delay_ms(5);
w_cmd(0x2e); /*Éýѹ²½¾Û2*/
delay_ms(5);
w_cmd(0x2f); /*Éýѹ²½¾Û3*/
delay_ms(5);
w_cmd(0x24); /*´Öµ÷¶Ô±È¶È£¬¿ÉÉèÖ÷¶Î§20¡«27*/
w_cmd(0x81); /*΢µ÷¶Ô±È¶È*/
w_cmd(0x1a); /*΢µ÷¶Ô±È¶ÈµÄÖµ£¬¿ÉÉèÖ÷¶Î§0¡«63 1f*/
w_cmd(0xa2); /*1/9ƫѹ±È£¨bias£©*/
w_cmd(0xc0); /*ÐÐɨÃè˳Ðò£º´ÓÉϵ½ÏÂ*/
w_cmd(0xa0); /*ÁÐɨÃè˳Ðò£º´Ó×óµ½ÓÒ*/
w_cmd(0x40); /*ÆðʼÐУº´ÓµÚÒ»ÐпªÊ¼*/
Clear_Screen();
w_cmd(0xaf); /*¿ªÏÔʾ*/
}
/**********************Clear*******************************/
void Clear_Screen(void)
{
unsigned char i,j;
for(i=0;i<9;i++)
{
LCD_CS=0;
w_cmd(0xb0+i);
w_cmd(0x10);
w_cmd(0x00);
for(j=0;j<132;j++)
{
w_dat(0);
}
}
}
一周热门 更多>