完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
嗨,伙计,我是新来的,因为我是新的微控制器编程。我有微芯片PIC3工具包,经过一些简单的练习,我想在LCD显示器上写点东西。LCD是一个带PCF877T控制器的SaNeWix04 4A。这工作在4引脚(SDA,SCL,VCC,GND),I连接到我的微芯片板的相应引脚(用于SDA的RB4和用于在这些端口上具有上拉电阻的SCL的RB6)。我的I2C协议的实现如下:现在我尝试了许多代码示例来初始化LCD,但是我有点困惑。关于一些事情:1)有可能驱动该死的显示器与8位接口?我发现的所有例子都是用4位接口驱动LCD的,它真的是CALID。2)我如何识别PIN的正确值?在数据表上,这是从1到16,但在许多例子中,我可以看到那些用二进制值映射的PIN。这是PIN的十进制值的二进制***吗?3)如何用I2C协议将一些PIN(例如RS和EN重要的话,如果你想发送数据到设备)高或低?我可以发送在最大8位,该设备如何理解这是一个8位序列驱动RS高?请给我一些例子,因为我已经尝试了很多解决方案,但什么都不奏效。也许LCD连接错了,我不知道,你能帮我吗?谢谢
以上来自于百度翻译 以下为原文 Hi guys, I'm new here as I'm new to microcontroller programming. I have the microchip pick3 kit and, after some simple excercise, I would like to write something on that LCD Display. The LCD is a sainsmart 2004A with pcf8574t controller. This works with 4 pin (SDA, SCL, VCC, GND) and I connect to the respective pin of my microchip board (RB4 for SDA and RB6 for SCL with pull up resistor active on these ports). My implementation of i2c protocol follows: void i2c_init(void) { #ifdef PULL_UPS WPUB4 = 1; WPUB6 = 1; nWPUEN = 0; //enable the global weak pull-up bit #endif SDA_DIR = 1; // Make SDA and SCK_DIR = 1; // SCK pins input PORTB = 0; // SSPADD = ((_XTAL_FREQ/4)/I2C_SPEED) - 1; SSPADD = 19; // BF RCinprocess_TXcomplete; UA dontupdate; SMP endsample_disable; P stopbit_notdetected; S startbit_notdetected; R_nW write_noTX; CKE tx_on_idle_to_active; D_nA lastbyte_address; SSP1STAT = 0x80; // SSPEN enabled; WCOL no_collision; SSPOV no_overflow; CKP lo_hold; SSPM I2CMaster_FOSC/4_SSPxADD; SSP1CON1 = 0x28; // ACKSTAT received; RCEN disabled; RSEN disabled; ACKEN disabled; ACKDT acknowledge; SEN disabled; GCEN disabled; PEN disabled; SSP1CON2 = 0x00; // BOEN disabled; AHEN disabled; SBCDE disabled; SDAHT 300nshold; ACKTIM ackseq; DHEN disabled; PCIE disabled; SCIE disabled; SSP1CON3 = 0x08; // SSPBUF 0x0; SSP1BUF = 0x00; // SSPMSK 0x0; SSP1MSK = 0x00; } void i2c_start() { SSP1CON2bits.SEN = 1; while(SSP1CON2bits.SEN); } void i2c_restart() { SSP1CON2bits.RSEN = 1; while(SSP1CON2bits.RSEN); } void i2c_stop() { SSP1CON2bits.PEN = 1; while(SSP1CON2bits.PEN); } void i2c_waitIDLE() { while( SSP1STATbits.R_nW | SSP1CON2bits.SEN | SSP1CON2bits.RSEN | SSP1CON2bits.PEN | SSP1CON2bits.RCEN | SSP1CON2bits.ACKEN ) { continue; } } void i2c_sendACK() { SSP1CON2bits.ACKDT = 0; SSP1CON2bits.ACKEN = 1; } void i2c_sendNACK() { SSP1CON2bits.ACKDT = 1; SSP1CON2bits.ACKEN = 1; } unsigned char i2c_sendByte(unsigned char data) { SSP1BUF = data; i2c_waitIDLE(); return (unsigned char)(!SSP1CON2bits.ACKSTAT); } void i2c_write(char addr,char data) { unsigned char collision; i2c_start(); i2c_restart(); collision = i2c_sendByte(addr); if (collision == -1) { SSP1CON1bits.WCOL = 0; } i2c_sendByte(data); i2c_stop(); i2c_waitIDLE(); } Now I try many code examples to initialize the LCD, but I'm a little bit confusing about some thing: 1) It is possible to drive that damned display with 8 bit interface?? All the examples I have found drive the LCD with 4 bit interface and it is really caotic. 2) How can I recognize the correct value of my PIN?? On the datasheet this goes from 1 to 16 but in many examples I can see those pin mapped with binary value. Is it the binary rappresentation of decimal value of the pin?? 3) How can put some of this pin (for example RS and EN are important if you want to send data to the device) high or low with i2c protocol?? I can send at max 8 bit and how can the device understand that is a 8 bit sequence to driving RS high? Please make me some example because I've tried a lot of solutions but nothing works... maybe the LCD is wrong connected I don't know.. Can you help me?? Thanks |
|
相关推荐
6个回答
|
|
它有一个I2C接口,我不认为你可以使用它-你可以选择另一个与旧的并行接口…你的I2C代码几乎可以对我来说,但它可能有一些问题(我总是喜欢一个软件,有点砰砰,解决方案…因为它更容易)。还要注意,“碰撞”是无符号字符,并与负数进行比较。
以上来自于百度翻译 以下为原文 It has an I2C interface, I don't think you can use parallel with it - you could pick another one with the old parallel interface... Your I2C code is almost ok to me, but it may have some issues (I always prefer a software, bit-banged, solution... since it's easier). Also note that "collision" is unsigned char and is getting compared to a negative number... |
|
|
|
但我的朋友告诉我,他设法使用它与ARDUINO板和液晶I2C库。这该死的表演让我发疯了。如果有人能帮我解决我写的问题,我会很高兴的。问题是如何识别PIN的二进制或十六进制值,以及如何发送RS和使能信号。谢谢大家。
以上来自于百度翻译 以下为原文 But my friend tell me that he manage to use it with arduino board and liquid Crystal i2c library.. I'm going mad whit this damned display. If there is someone that could help me about the questions I have written I will so happy.. The problem is how recognize the binary or hex value of the pin and how send the RS and Enable signal. Thank you all |
|
|
|
串行(I2C)显示器不运行这种方式(RS和使能信号)。我认为你最好阅读一个数据表来显示这个部分的串行协议/命令结构。
以上来自于百度翻译 以下为原文 Serial (i2c) displays don't operate that way (RS and Enable signal). I think you better read a data sheet for the display to see what the serial protocol/command structure is for this part. |
|
|
|
嗨,首先,马上离开,不要使用内部的上拉你的I2C总线。总线上的拖动必须是外部的,否则操作可能不起作用。而且,论坛实际上不打算为您编写代码。如果你对PIC设备有疑问,这是个地方,但它不是让人们为你编写代码的地方。你的问题是:1。I2C协议发送8位数据。我不确定你所说的4位接口是什么意思。I2C使用SCL和SDA线,因此只需要2个引脚。请解释你所说的4位接口的含义。2。你的PIN的正确值是什么意思?我真的不明白你在问什么。请澄清这个问题。3。你需要检查数据表。如果控制器可以接受命令来设置一个PIN,那么在这个数据表中应该有一个命令用于这个目的。如果没有,那么你必须用微控制器的I/O引脚控制那些引脚,或者把它们拴在一个固定的逻辑电平上。如果你不确定LCD或驱动程序是如何工作的,你可以考虑给制造商发电子邮件。它们将是你获得正确信息的最好机会,也可能是代码例子。克里斯
以上来自于百度翻译 以下为原文 Hi, First, right off the bat, do NOT use internal pull-ups for your I2C bus. Pull-ups on the bus must be external, otherwise operation is probably not going to work. Also, the forum is really not intended to write code for you. If you have questions about a PIC device, this is the place, but it is not the place to have people write code for you. Your questions: 1. I2C protocol sends 8 bits of data. I'm not sure what you mean by 4 bit interface. I2C uses the SCL and SDA lines, so only 2 pins are needed. Please explain what you mean by 4 bit interface. 2. What do you mean by correct value of your pin? I really can't understand what it is you're asking. Please clarify this question. 3. You need to check the data sheet. If the controller can accept commands to set a pin, then there should be a command listed in the data sheet for this purpose. If there isn't, then you have to control those pins with I/O pins from the microcontroller, or tie them to a fixed logic level. If you are not sure about how the LCD or driver works, you may consider emailing the manufacturer. They would be your best chance of getting correct information, and possibly code examples. ~ Chris |
|
|
|
大家好,我知道OP正在尝试使用一个44780兼容的LCD和一个PHIPS I2C 8位端口扩展器,用I2C总线驱动LCD。在这种情况下,你必须配置LCD精确地工作在4位模式下。检查4位M中的44780个控制器初始化数据表的数据表。ODE、RS和E,最终RW将连接到PCF854并行端口的其余4个引脚中的任何一个。您将不得不通过I2C发送在这种模式下初始化所需的所有数据。一旦在4位模式下,您将发送数据和命令一次一个半字节,这篇文章可能是HelpFTPS://V2Cuy.WordPress…CD-OW-PCF8544/它在French,但它不难理解,它有图表和代码。
以上来自于百度翻译 以下为原文 HI all, I understand the OP is trying to use an 44780 compatible LCD with a Phiips I2C 8bit port expander in order to drive the lcd using the I2C bus. In that case, you must configure the LCD to work precisely in 4 bit mode. Check the data sheet of the 44780 controller initializing sequence in 4 bit mode. RS and E and eventually RW will be connected to any of the 4 remaining pins of the parallel port of the PCF8574. You will have to send via I2C all the data needed for initialization in such mode. Once in 4 bit mode, you will send data and commands splitted in half, one nibble at a time. May be this article will help https://ve2cuy.wordpress....cd-with-pcf8574/ It´s in French but its no difficult to understand and it has diagrams and code. Regards Bill |
|
|
|
多谢你的回复,你说得对,那就是我想做的事!但我不知道如何解释这些别针的价值…在数据表中,PIN从1到16编号,例如,RS是PIN号4。这可能意味着:阅读一些图书馆,例如ARDUIO SurCurralI2Ic,我读到:谢谢比尔。
以上来自于百度翻译 以下为原文 Thanks a lot Bill for your reply, you're right that's what I want to do! But I don't know how interpret the value of those pins... In the datasheet the pin is numbered from 1 to 16 and, for example, RS is pin number 4. This maybe means that: RS 0b00000100 // 4 in binary? Reading some library, for example the arduino LiquidCrystal_i2c, I read: unsigned char _Rs = 1<<4; Thank you Bill |
|
|
|
只有小组成员才能发言,加入小组>>
5171 浏览 9 评论
2001 浏览 8 评论
1931 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3176 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2228 浏览 5 评论
737浏览 1评论
622浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
509浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
635浏览 0评论
533浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 05:12 , Processed in 1.380582 second(s), Total 88, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号