完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
大家好!我一直试图连接我的PIC16F630到我的液晶模块在4位模式。我已经编写了一些代码,我认为会在LCD上初始化4位模式,然后使LCD闪烁。定义E 4 RC2α定义D5 RC3α定义D7 RC4α定义包含D7 RC.H;gt;包含“配置h”空隙写(int a,int b,int c,int d){a=DelayyMs(20);d4= a;d5= b;d7= c;d7= d;RS=0;e=1;α-DelayyMS(20);e=0;}空隙主(空隙){PtCc=这是我的源代码:0;E=0;写(1,1,0,0);写(1,1,0,0);写(1,1,0,0);写(0,1,0,0);写(1,1,1,1);写(0,0,0,0);}我用PIN RC0—RC5在我的PIC上,你可以看到每个人都与代码中的前6宏连接。
以上来自于百度翻译 以下为原文 Hello everyone! I've been trying to connect my PIC16f630 to my LCD module in 4 bit mode. I have written some code that I thought would initialize 4 bit mode on the LCD and then make the LCD blink. Here is my source code: #define RS RC0 #define E RC1 #define D4 RC2 #define D5 RC3 #define D6 RC4 #define D7 RC5 #include #include "config.h" void write(int a, int b, int c, int d) { __delay_ms(20); D4 = a; D5 = b; D6 = c; D7 = d; RS = 0; E = 1; __delay_ms(20); E = 0; } void main(void) { PORTC = 0; E = 0; write(1,1,0,0); write(1,1,0,0); write(1,1,0,0); write(0,1,0,0); write(1,1,1,1); write(0,0,0,0); } I'm using pins RC0 - RC5 on my PIC, you can see what each one is connected to with the first 6 macros in the code. Any and all help is greatly appreciated. |
|
相关推荐
3个回答
|
|
你从不向TrISC写这些引脚输出。不要用“int”变量来计算字节,这对8位控制器来说是非常低效的。改为使用“无符号字符”。
以上来自于百度翻译 以下为原文 You never write to TRISC to make those pins outputs. Don't use "int" variables for bytes, that's horribly inefficient on an 8 bit controller. Use "unsigned char" instead. |
|
|
|
嗨,我认为你的参数列表中的位序列很笨拙,参数列表中的第一个(最左边)的参数进入小写中的最低有效位。这与日立HD44 780数据表中的命令表和示例完全相反,您可以找到代码示例。在最左边的位置写数字中最重要的数字,然后在PIC16F630和类似的微控制器上,不可能读取输出锁存器,即没有LATC寄存器,当在同一端口R中更新位时,程序面临读取修改写入问题的风险。你可能需要使用一个影子寄存器来让它可靠地工作。更高的指令频率会使RMW问题变得更糟。第一个3字节写是一种已知的在8位模式下初始化显示的好方法。第4个半字节写将把显示带到4位模式。由于写之后,将一起2,形成一个8位字节。函数集操作应与低字节MysIL中的N和F参数重复。
以上来自于百度翻译 以下为原文 Hi, I think the Bit Sequence in your argument list is awkward, the first,(leftmost) argument in argument list, goes into the Least significant bit in the nibble. This is exactly opposite of command tables and examples in Hitachi HD44780 datasheet, and code examples you may find. In primary school, I was tought to write the most significant digit in a number, in the leftmost position. Then on PIC16F630 and similar microcontrollers without possibility to Read the output Latchches, that is without LATC register, the program is at risk of Read-Modify-Write problems, when updating bits in the same Port register in close sequence. You may need to use a Shadow register to get it to work reliably. Higher instruction frequency will make RMW problems worse. The first 3 nibble writes is a known good way to initialize the display in 8 bit mode. The 4.th nibble writes will bring the display to 4 bit mode. Following writes after that will go 2 together to form a 8 bit byte. The Function set operation should repeated with N and F parameters in the low nibble ... write(1,1,0,0); /* Reset to 8 bit mode */ write(1,1,0,0); /* reset to 8 bit mode */ write(1,1,0,0); /* --- " ---- */ write(0,1,0,0); /* Set 4 bit mode */ write(0,1,0,0); /* Function Set Command, Confirm 4 bit mode */ write(0,0,0,1); /* Low nibble of Function Set command, 2 line 5x8 font */ write(0,0,0,0); /* Display on/off control, High nibble is transferred first. */ write(1,1,1,1); /* Display On, Cursor On, Blink On. */ write(0,0,0,0); /* Entry mode set */ write(0,1,1,0); /* Increment */ RS = 1; write(D4,D5,D6,D7); /* Character Write, High nibble first */ write(D0,D1,D2,D3); /* Character Low nibble. */ Mysil |
|
|
|
如何使用MPLAB C30编译程序在4位模式下使用DSPL30F.AM制作16X1 LCD。请帮助我完成这个程序。
以上来自于百度翻译 以下为原文 HOW CAN I MAKE 16X1 LCD IN 4 BIT MODE WITH DSPIC30F. AM USING MPLAB C30 COMPILER. PLEASE HELP ME FOR THE PROGRAM. |
|
|
|
只有小组成员才能发言,加入小组>>
5234 浏览 9 评论
2026 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3201 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
771浏览 1评论
659浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
588浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
670浏览 0评论
571浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-20 20:15 , Processed in 1.358203 second(s), Total 82, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号