Welcome! Log In Create A New Profile

Advanced

i2c commands

Posted by auntybellum 
i2c commands
January 13, 2013 08:41PM
I am trying to get my Byvac BV4618 to work via i2c. I can get it to display any text I like (Hello World and all the rest) but I am struggling to control the cursor.
The two documents I have found contradict each other. The 'Datasheet' says 0x1b 1 1 clears the screen (it doesn't) and the 'User Guide' claims that 0x1b 50 clears the screen (it does). But try as I might I cannot move the cursor. The Datasheet oddly says that "if the cursor has reached the top of the display the command is ignored" for all four 'move cursor commands' - up, down, left and right. Which implies that if you ever get the cursor to the top then tough luck - there it stays. I am assuming that an 0x1b (escape) plus something will move it. Anybody been using i2c and can help me out please?
Re: i2c commands
January 14, 2013 10:36AM
The fact that 1b 50 works and 1b 1 1 doesn’t points to something amiss with what is being sent, this would also account for the problems with moving the cursor. It looks as though the master I2C is capable of sending 2 bytes (1b 50) but not 3 or more.
Re: i2c commands
January 14, 2013 04:55PM
Thank you but I can send any unbroken stream of i2c characters to display Hello World or the complete works of Shakespeare and they display perfectly as per ASCII codes. But I can't get these control codes right.
Re: i2c commands
January 14, 2013 05:35PM
Some questions:
1) What value of pull up resistors are you using?
2) What is the host?, the master device
3) What size is the display
Re: i2c commands
January 14, 2013 07:39PM
1) They are integrated as part of a level translator module as the LCD runs at 5v and my PIC runs at 3.3v as the two SDA/SCL have to be isolated. Resistor values are only critical if you worry about bus capacitance to get higher speeds and/or many slaves. I am operating the i2c bus very slowly (obviously you can actually stop and restart i2c - one of its beauties). Just to repeat - I have no problem driving the i2c bus. I can send any stream to the LCD and they are all displayed. None are missed. If the pull ups were too low then no comms would ever pass down the bus at all - that's how i2c works. If they are too high then ACKs would be missing from the slave and the transfer would stop. I have another slave that reads and writes on the same i2c (also on the 5v side) and that reads and writes just fine. There is no problem with the i2c comms.
2)It's a PIC 24FJ64GA002
3)20x4

The problem is just the control codes. I'm trying to find someone who has used i2c with the BV4618 rather than through Arduino and find which control codes they used and whether the BV4618 needs a delay with these commands. I know it sends ACK, as appropriate, but I don't know if I have a buffer in the BV4618 which I am overunning, whereas ASCII codes for the screen just pass straight through to be displayed (as they are).

Thank you again.
Re: i2c commands
January 15, 2013 08:53AM
I asked about the value of the resistors just to make sure that you are aware and its obvious that you know what you are doing - it is a good question to solicit that information.

At some point you need to set the BV4618 to have 4 lines by 20 charters as the default is 16x20, this will affect cursor movements outside that range. It works by using the values stored in EEPROM set by the 0x32 command. The defaults work for most displays.

I can say the BV4618 has a 32 byte input buffer and a 1 byte output buffer. If you have enabled ACK then it MUST be read – this is not made clear in the data sheet.

The easiest thing to concentrate on is why 0x1b 1 1 does not work? This is the data sequence:

<start condition> 0x62 0x1 0x1 <stop condition>

This simply sends the second 0x1 as a command (with RS low) to the display. Does the master implement clock stretching? The BV4618 will hold the clock line low until it has finished, or more accurately until the LCD has finished. If the master does not recognise this then the second byte may get lost. A quick test for this is to insert a delay between sending bytes.
Re: i2c commands
January 16, 2013 08:14PM
Hello Jimeer,
Sorry for the late reply. I've been away from my desk lately. I'll ponder what you said and maybe run some code to see if I can deduce what is happening. I have sent the codes for 4 lines and 20 columns but as I can't make the cursor jump I can not be sure. If I send enough text it gets to the third an d fourth lines.
I have been suspicious that the Byvac can send ASCII to the display in the time of one byte transmission but the commands have to be processed before sending to the HD44870 and it doesn't have time.
I take your point about the slave forcing a clock stretch after it pulls the ACK on SDA and the master missing it but clock stretching happens in the slave. The Byvac can (if it's so programmed) hold SCL down after sending ACK on the ninth bit. The SCL being held low won't allow the Master's baud rate generator to time the next clock pulse (so data can be laoded onto the SDA) so the master is forced to hold. I think the PICs are configured like that so that when the slave finally releases SCL then a full clock is generated. I'm not sure but I don't think a master can 'miss' a clock stretch as it can't get SCL high again! I think all masters in i2c have to be configured like that. I may be making the problem worse because I am running i2c within a high priority interrupt service routine and not leisurely polling so even though I'm running a slow clock the Byvac may be overrun.
Thanks again
Barry S.
Sorry, only registered users may post in this forum.

Click here to login