PDA

View Full Version : problem with I2CWRITE command



hatzukitzuki
- 10th October 2010, 12:34
I have a problem with I2CWRITE command.
I am using LAB X1 with 16F877 and with PicBasicPro v.2.6.
To pins C3,C4 is connected a LCD display having I2C interface BV4512 from ByVac.

Here is my test program:


SCL VAR PORTC.3 ' Clock pin
SDA VAR PORTC.4 ' Data pin
adr_bv VAR WORD ' address for I2C LCD
cmd_bv VAR BYTE ' command to I2C LCD
data_1 VAR BYTE ' Data 1
data_2 VAR Byte ' Data 2

adr_bv = $42 ' I2C address
cont CON %10100000 ' control

cmd_bv = $05
I2CWrite SDA,SCL,cont,adr_bv, [cmd_bv] ' Reset I2C LCD display
Pause 100

cmd_bv = $03
I2CWrite SDA,SCL,cont,adr_bv,[cmd_bv,$9A] ' write character $9A on position 0,0
PAUSE 500

cmd_bv = $20
I2CWrite SDA,SCL,cont,adr_bv,[cmd_bv,$41] ' write character A on position 0,0
Pause 1000

End

The commands $05 and $03 are working (control is not important), the command $20 and all other commands defined by ByVac don't work.

My first question is, what purpose has "control" in the I2CWRITE command. In the online manual is nothing about that.

Second, does somebody has an experience with ByVac I2C interface? Any suggestion is welcomed.

mackrackit
- 11th October 2010, 10:07
My first question is, what purpose has "control" in the I2CWRITE command. In the online manual is nothing about that.
Maybe you should look in the manual that came with PBP when you purchased it??

hatzukitzuki
- 14th October 2010, 13:47
Maybe you should look in the manual that came with PBP when you purchased it??

Goog Idea, however I diid it before I opened this thread. Also I have read the on-line help of P2P. Both are the same. Nothing about "control" in I2CWRITE command. I have read all threads about I2C on this forum. It appears more users have problems with I2CWRITE.

In this moment I am using I2C analyzer and doing tests of communication on the I2C bus during I2CWRITE command. I think, the I2CWRITE doesn't work correctly. The problem isn't in hardware LAB-X1 and/or ByVac I2C LCD interface. The problem is in the P2B. The I2C is usable maybe for single EEPROM but not master/slave I2C devices on the bus.

cncmachineguy
- 14th October 2010, 14:09
cmd_bv = $03
I2CWrite SDA,SCL,cont,adr_bv,[cmd_bv,$9A] ' write character $9A on position 0,0
PAUSE 500


So the above works and ,


cmd_bv = $20
I2CWrite SDA,SCL,cont,adr_bv,[cmd_bv,$41] ' write character A on position 0,0
Pause 1000


This doesn't?

That seems very odd. the only difference being cmd_bv. If I2CWrite is not working, I would expect all to fail, not just the last 1. I suspect some condition has not been met. Does your analyzer show the first 2 outputs are good? then the last is bad?

I see my manual also says nothing about what control does, but I suspect it is for read or write. In any event, you have not changed it between the 3 commands, so why do you think it doesn't work?

hatzukitzuki
- 14th October 2010, 14:32
Bert (and all),
the problem around I2C is more complicated as I have thought earlier. First, to understand both examples (working and non-wirking) above, it is necessary to study ByVac I2C LCD datasheet. The command $03 writes directly to LCDcontrollers, while command $20 recall routines of the MCU on he I2C ByVac LCD controller. There are of course more commands.

I did tests with all ByVac commands and changed step by step the "control" variable at I2CWRITE bit by bit. The "control" variable has no influence to I2CWRITE. Still I don't understand it's meaning.

The I2C analyzer shows bus conflicts / errors. On another place of this forums, in one thread, I have read user's problem with I2CWRITE in case of master/slave devices.

On the other hand, if I use assembler and write the communication from LAB-X1 to ByVac I2C interface to LCD in assembler, I can use without problems all ByVac interface's commands ... $03, $20, $25... etc., while PBP has problems.

cncmachineguy
- 14th October 2010, 15:00
Is the above your full test program? Have you told PBP osc speed? I will go try to find a datasheet for byvac lcd.

mackrackit
- 14th October 2010, 15:11
First off, when you said you looked at the online manual I figured you did not have the printed manual meaning ....
For that I apologize.

Th control is specific to the part being used. I have not used the part you are using so I will need to look at the data sheet when I get back to the shop.

Control does have read/write bits set but normally PBP will changes those for you at compile time.

In th meantime maybe this will help, maybe a work around if PBP does not work well with your part.
http://www.picbasic.co.uk/forum/content.php?r=165-Serial-EEPROM-Part-1

mackrackit
- 14th October 2010, 22:35
Assuming this is the data sheet
http://www.i2c.byvac.com/downloads/BV4512%20DataSheet.pdf


On the other hand, if I use assembler and write the communication from LAB-X1 to ByVac I2C interface to LCD in assembler, I can use without problems all ByVac interface's commands ... $03, $20, $25... etc., while PBP has problems.
From what I see on the above data sheet that would be correct. The display is not setup to have more than one on a bus so it does not use a control bit.

Looks like you will have to use SHIFTOUT. But if you have an ASM routine working just put that into the PBP code.