完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
我用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 selection(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); } } } |
|
相关推荐
1个回答
|
|
lcd头文件如下
#ifndef _LCD_H_ #define _LCD_H_ #include "delay.h" //#include "intrins.h" //#include //#define extern deep[] #define VC_ON 0x2C //1010 #define VR_ON 0x2A #define VF_ON 0x29 //1001 #define Data GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15 #define LCD_Read PAout(4) #define LCD_RW PAout(3) #define LCD_RS PAout(2) #define LCD_RES PAout(1) #define LCD_CS PAout(0) //#define LCD_Read GPIO_Pin_4 //#define LCD_RW GPIO_Pin_3 //#define LCD_RS GPIO_Pin_2 //#define LCD_RES GPIO_Pin_1 //#define LCD_CS GPIO_Pin_0 void LCD_Reset(void); void w_dat(unsigned char dat); //дÊý¾Ý void w_cmd(unsigned char cmd); //д¿ØÖÆÖ¸Áî void Display(unsigned char *p); void Display_fill(unsigned char fill); void Grid_white(void); void Grid_Black(void); void Grid_Line1(void); void Grid_Line2(void); void Lcd_Init(void); void Clear_Screen(void); #endif |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
STM32CUBEMX(5)--自定义红外NEC解码,定时器TIM捕获方式
503 浏览 0 评论
stm32f407vet6+LAN8720A调试以太网遇到软件复位失败问题
867 浏览 0 评论
使用STM32CubeMX对红外波形进行GPIO输出,并LED显示
421 浏览 0 评论
462 浏览 0 评论
1170 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-9-10 11:23 , Processed in 0.557617 second(s), Total 72, Slave 54 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191