完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
检测LCD1602忙信号程序如下,实现不了,有没有好的改进方案,或其他好的建议,(我已经用延时替代忙信号检测实现了字符显示)
uint8_t ReadDataPort(void) { uint32_t temp; GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); 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_Pin_7; GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU; GPIO_Init(GPIOA,&GPIO_InitStructure); temp=GPIOA->IDR; 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_Pin_7; GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP; GPIO_Init(GPIOA,&GPIO_InitStructure); return (uint8_t)temp; } void WaitForEnable(void) { uint8_t val; WriteDataPort(0xff); LCM_RS_0;LCM_RW_1;delay_us(1); LCM_EN_1;delay_us(1); val=ReadDataPort(); while(val&0x80) val=ReadDataPort(); LCM_EN_0; } |
|
相关推荐
12个回答
|
|
额,我用的好像从来不检测忙的。。直接拿来显示
|
|
|
|
|
|
|
|
|
|
支持一下,学习
|
|
|
|
云汉达人
#include "lcd16032.h" #include "delay.h" const uint8_t LCD_DAT0[]="白日依山尽黄河入海流"; const uint8_t LCD_DAT1[]="欲穷千里目更上一层楼"; const uint8_t LCD_DAT3[]="好雨知时节当春乃发生"; const uint8_t LCD_DAT4[]="随风潜入夜润物细无声"; //////////1602写指令函数//////// void LCD16032_writeCom(uint8_t com) { // busy(); LCD_RS_LOW; LCD_RW_LOW; LCD_EN_LOW; Delay(1000); LCD_EN_HIGH; Delay(1000); LCD_DATA=0XFF00&(com<<8); Delay(1000); LCD_EN_LOW; } //////////1602写数据函数//////// void LCD16032_writeData(uint8_t wdata) { LCD_RS_HIGH; LCD_RW_LOW; LCD_EN_LOW; Delay(1000); LCD_EN_HIGH; Delay(1000); LCD_DATA=0XFF00&(wdata<<8); Delay(1000); LCD_EN_LOW; } //////////初始化1602写指令函数//////// void LCD16032_init(void) { LCD16032_writeCom(0x30); //0011 1000 Delay(2000); LCD16032_writeCom(0x30); Delay(2000); LCD16032_writeCom(0x0F); Delay(2000); LCD16032_writeCom(0x06); Delay(2000); LCD16032_writeCom(0x01); Delay(2000); } //////////初始化1602写数据函数//////// void LCD16032_initWriteData(void) { uint8_t i; LCD16032_writeCom(0x80); for(i=0;i<20;i++) { LCD16032_writeData(LCD_DAT3); } LCD16032_writeCom(0x90); for(i=0;i<20;i++) { LCD16032_writeData(LCD_DAT4); } } void LCD16032_WriteData(uint8_t xpos,uint8_t ypos,uint8_t Data) { uint8_t address; if(ypos==0) {address = 0x80 + xpos;} else if(ypos==1) {address = 0x90 + xpos;} LCD16032_writeCom(address); LCD16032_writeData(Data); } void LCD16032_WriteString(uint8_t xpos,uint8_t ypos,uint8_t *DisplayString) { uint8_t address; if(ypos==0) {address = 0x80 + xpos;} else if(ypos==1) {address = 0x90 + xpos;} LCD16032_writeCom(address); while(*DisplayString) { LCD16032_writeData(*DisplayString); DisplayString++; } } void LCD16032_WriteString_shift(uint8_t xpos,uint8_t ypos,uint8_t *buf) { uint8_t m1; for(m1=0;m1<10;m1++) { LCD16032_WriteString(m1+xpos,ypos,buf); Delay(0xffffff); LCD16032_writeCom(0x01); Delay(0xffff); } } void LCD_GPIO_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); //PIN8~15 = DB0~7 GPIO_InitStructure.GPIO_Pin =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_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOE, &GPIO_InitStructure); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Pin =GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOA, &GPIO_InitStructure); } |
|
|
|
云汉达人
#include "lcd16032.h" #include "delay.h" const uint8_t LCD_DAT0[]="白日依山尽黄河入海流"; const uint8_t LCD_DAT1[]="欲穷千里目更上一层楼"; const uint8_t LCD_DAT3[]="好雨知时节当春乃发生"; const uint8_t LCD_DAT4[]="随风潜入夜润物细无声"; //////////1602写指令函数//////// void LCD16032_writeCom(uint8_t com) { // busy(); LCD_RS_LOW; LCD_RW_LOW; LCD_EN_LOW; Delay(1000); LCD_EN_HIGH; Delay(1000); LCD_DATA=0XFF00&(com<<8); Delay(1000); LCD_EN_LOW; } //////////1602写数据函数//////// void LCD16032_writeData(uint8_t wdata) { LCD_RS_HIGH; LCD_RW_LOW; LCD_EN_LOW; Delay(1000); LCD_EN_HIGH; Delay(1000); LCD_DATA=0XFF00&(wdata<<8); Delay(1000); LCD_EN_LOW; } //////////初始化1602写指令函数//////// void LCD16032_init(void) { LCD16032_writeCom(0x30); //0011 1000 Delay(2000); LCD16032_writeCom(0x30); Delay(2000); LCD16032_writeCom(0x0F); Delay(2000); LCD16032_writeCom(0x06); Delay(2000); LCD16032_writeCom(0x01); Delay(2000); } //////////初始化1602写数据函数//////// void LCD16032_initWriteData(void) { uint8_t i; LCD16032_writeCom(0x80); for(i=0;i<20;i++) { LCD16032_writeData(LCD_DAT3); } LCD16032_writeCom(0x90); for(i=0;i<20;i++) { LCD16032_writeData(LCD_DAT4); } } void LCD16032_WriteData(uint8_t xpos,uint8_t ypos,uint8_t Data) { uint8_t address; if(ypos==0) {address = 0x80 + xpos;} else if(ypos==1) {address = 0x90 + xpos;} LCD16032_writeCom(address); LCD16032_writeData(Data); } void LCD16032_WriteString(uint8_t xpos,uint8_t ypos,uint8_t *DisplayString) { uint8_t address; if(ypos==0) {address = 0x80 + xpos;} else if(ypos==1) {address = 0x90 + xpos;} LCD16032_writeCom(address); while(*DisplayString) { LCD16032_writeData(*DisplayString); DisplayString++; } } void LCD16032_WriteString_shift(uint8_t xpos,uint8_t ypos,uint8_t *buf) { uint8_t m1; for(m1=0;m1<10;m1++) { LCD16032_WriteString(m1+xpos,ypos,buf); Delay(0xffffff); LCD16032_writeCom(0x01); Delay(0xffff); } } void LCD_GPIO_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); //PIN8~15 = DB0~7 GPIO_InitStructure.GPIO_Pin =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_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOE, &GPIO_InitStructure); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Pin =GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOA, &GPIO_InitStructure); } |
|
|
|
|
|
|
|
没有用中断调试过,我用延时替代忙检测,LCD可以显示的;现在我的疑问是在配置GPIO引脚时是输出模式,但是忙检测是要用输入模式的吧,怎么切换这两种模式呢?还是不用切换就能读引脚的电平呢
|
|
|
|
这个程序也没有用忙检测的吧
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
856 浏览 0 评论
1184 浏览 1 评论
2560 浏览 5 评论
2893 浏览 9 评论
移植了freeRTOS到STMf103之后显示没有定义的原因?
2750 浏览 6 评论
keil5中manage run-time environment怎么是灰色,不可以操作吗?
1181浏览 3评论
213浏览 2评论
481浏览 2评论
397浏览 2评论
M0518 PWM的电压输出只有2V左右,没有3.3V是怎么回事?
478浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-14 06:04 , Processed in 1.397248 second(s), Total 99, Slave 80 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号