完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,这是我在论坛上的第一篇文章,我搜索了这个话题,但是找不到。不管怎样,我有一个IC2模块,特别是PCF887A,我把它连接到PIC1845,这样我就可以通过I2C稍后使用LCD。问题是每当我把数据发送到I2C模块时,似乎每个字节的字节都被交换。所以,如果我发送一个0x0f,它显示0xf0。我试图使用一个交换函数,但没有解决这个问题,它发送了0xFF,我知道我的交换函数工作,因为我尝试把数据显示到PORTC(或任何端口),它实际上交换了啃咬。这是我第一次为PIC18工作I2C,所以我可能缺少一个配置。我附上我的代码仅供参考。任何帮助都会被感激的。艾莉尔
以上来自于百度翻译 以下为原文 Hi, This is my first post on the forum and I have searched for this topic, but could not find it. Anyway, I have an IC2 module, specifically the PCF8574A, and I connected it to the PIC184550 so that I can use the LCD later via i2c. The problem is that whenever I send data to the i2c module, it seems that the nibbles of each byte are being swapped. So, if I send an 0x0F, it displays 0xF0. I tried to use a SWAP function but did not fix the problem, it sends 0xFF, and I know my SWAP function works because I tried displaying the data into PORTC (or any port) and it actually swaps nibbles. This is my first time working on i2c for PIC18, so I might be missing a configuration. I attach my code just for futher references. Any help would be appreciated. Ariel Attachment(s) main.c (5.70 KB) - downloaded 55 times |
|
相关推荐
7个回答
|
|
嗨,我也有IC2的问题。看看我的线。也许有一个为你服务……“PIC18F46K22I2C不工作”
以上来自于百度翻译 以下为原文 Hi, I have problems with IC2, too. Look at my thread. Maybe there is a solutotion for you... "PIC18F46K22 I2C doesn´t work" |
|
|
|
嗨,代码1中的代码似乎是一个合理的第一次努力,也许大部分是从某处借来的。在I2C.MistRoad Wrand(…)中交换;永远不能工作,因为这会损坏I2C从地址,这是在数据字节之前发送的。我将检查PCF88A扩展之间的连接。R和任何与一些可疑的事物有关。请注意,当在一个字节内标记位时,最低值表示最低有效位。我期望0xf0出现为p7=1,p6=1,p5=1,p4=1,p3=0,p2=0,p1=0,p0=0。但此扩展器旨在驱动与电阻器连接到VCC的LED指示器,P。在这方面,低输出会使LED亮起来,高输出会使它变暗。而不是改变位序列,你可以尝试颠倒数据字节。倾斜'~’字符是C语言运算符的“位不”,这意味着每个位都颠倒过来。读取PCF87A扩展器数据表,可以从TI网站下载。迈西尔
以上来自于百度翻译 以下为原文 Hi, Code in message #1 seem like a reasonable first effort, maybe most of it is borrowed from somewhere. Swapping in I2C_Master_Write(...); could never work, because that would mangle the I2C slave address, that is sent before the data bytes. I would examine the connection between the PCF8574A expander and whatever with some doubth. What is connected to Be aware that when labeling bits within a byte, then the lowest number mean the least significant bit. I would expect 0xF0 to appear as P7 =1, P6 = 1, P5 = 1, P4 = 1, P3 = 0, P2 = 0, P1 = 0, P0 = 0. But this expander is intended to drive LED indicators that are connected with a resistor to Vcc, the positive power supply. In this connection, a Low output will make the LED light up, and High output will make it dark. Instead of changing sequence of bits, you may try to Invert the data byte only. I2C_Master_Write( ~ 0xF0 ); the tilde '~' character is a C language operator 'bitwise not' that mean each bit be turned upside down. Read Datasheet for PCF8574A expander, it can be downloaded from TI website. Mysil |
|
|
|
感谢所有,我解决了我的问题,这似乎是我使用错误的从地址。现在我已经为I2C实现了功能,但是现在我遇到了一个新的问题。我可以通过设置光标回家和闪烁来设置LCD。但是,由于某种原因,当我发送数据而不是命令时,我不能使它工作。我在想,也许是连接到液晶显示器的RS引脚的PIN不能正常工作,但是当我尝试将数据发送到LCD时,它实际上打开了。事实上,所有的I2C模块的引脚工作。我把我项目的链接发送给你。http://Github.com/Helo…20编程/计时器。谢谢!
以上来自于百度翻译 以下为原文 Thanks to all, I solved my problem and it all seemed to be that I was using the wrong slave address. Now the functions I have implemented for I2C work, but now I encounter a new problem. I am able to setup the LCD by setting the cursor home and blinking. But, for some reason, I cannot make it work when I send data instead of commands. I was thinking that perhaps the pin that is connected to the Rs pin of the LCD was not working properly, but it actually turns on when I try to send data to the LCD. In fact, all pins of the I2C module work. I send you the link of my project. https://github.com/hearco...20programming/TIMERS.X Thanks! |
|
|
|
这是正确的计划吗?在那里我看不到任何I2C或LCD代码,只是定时器。
以上来自于百度翻译 以下为原文 Is that the right project? I cannot see any I2C or LCD code in there, just timers. |
|
|
|
|
|
|
|
HI,在GITHUB上发布的代码,下面的字节将从I2C主机转移:无论PCF扩展器和LCD显示器之间的布线如何安排,使用I2CYLCDWRead字节(…)发送4位命令到显示控制器,将扰乱所有以下命令的同步在接收到4位命令的第一个字节后,显示控制器将改变通信模式,最好单独做一个功能,发送一个半字节到显示控制器。我没有看到任何配置位设置,所以不知道什么频率的CH。IP实际上是运行的。对于I2C通信来说,实际频率并不重要,只要它不是太高,但是显示控制器对一些命令有不同的时序要求。如果通信的定时被提高,一些命令可能需要额外的延迟。周围的小乌鸦。问候,Mysil
以上来自于百度翻译 以下为原文 Hi, With the code posted on Github, the following bytes will be transferred from I2C master: Start 0x7E // I2C slave address 0x4C E^ // 4bit 0x48 Ev 0x1C E^ 0x18 Ev > /* After 4bit command have been given, display controller will take these two nibbles together */ 0x0C E^ / // Clear screen 0x08 Ev / 0x8C E^ 0x88 Ev > 0x0C E^ / // Cursor ON 0x08 Ev / 0xFC E^ 0xF8 Ev ... Whatever way the wiring between PCF expander and LCD display may be arranged, using I2C_LCD_WriteByte(...) to send the 4-bit command to Display controller, will mess up synchronization for all following commands and data. Immediately after receiving the first nibble of 4-bit command, display controller will change communication mode. It will be better to make a separate function to send a single Nibble to display controller. I have not seen any Configuration bit settings, so do not know what frequency the chip is actually running. For I2C communication, actual frequency do not matter, as long as it is not much too high, but Display controller have different timing requirements for some commands. If timing in communication is thightened up, additional delay may be needed for some commands. There are some other small uglies around. Regards, Mysil |
|
|
|
对不起,DavidBlit是对的。这是一个项目:http://Github.com/HyoCo/PIC18/Trime/Mc/C%20%编程/I2CLCD。XMysil,UC工作在16MHz,但我将在项目上添加明确的配置来解决这个问题。我知道LCD有它自己的时间要求,但是我在想如果我能把LCD打开和闪烁,我也能显示任何字符,但是它没有发生。我想我会再次检查时间要求,看看数据是否被正确地发送。此外,我还要检查发送的NIbBLE函数,看看它是否有效,并在这里发布我的更新。
以上来自于百度翻译 以下为原文 Sorry, DavidBlit is right. This is the project: https://github.com/hearco/PIC18/tree/master/C%20programming/I2C_LCD.X Mysil, The uC is working at 16MHz, but I will add explicit configurations on the project to address that. I know that the LCD has its own time requirements, but I was thinking that if I am able to set the LCD on and blinking, I should be able to display any character as well, but it is not happening. I think I will check on the time requirements again to see if a data is not being sent properly. Also, I will also check on the sending nibbles function to see if that works and post my update here. Thanks all, |
|
|
|
只有小组成员才能发言,加入小组>>
5162 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3172 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
731浏览 1评论
613浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
503浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
629浏览 0评论
527浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 10:47 , Processed in 1.452899 second(s), Total 90, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号