problem with I2CWRITE command


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2010
    Location
    Northants
    Posts
    4

    Default problem with I2CWRITE command

    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.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    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??
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Oct 2010
    Location
    Northants
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    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.

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by hatzukitzuki View Post
    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?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  5. #5
    Join Date
    Oct 2010
    Location
    Northants
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    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.

  6. #6
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Is the above your full test program? Have you told PBP osc speed? I will go try to find a datasheet for byvac lcd.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    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/cont...-EEPROM-Part-1
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Assuming this is the data sheet
    http://www.i2c.byvac.com/downloads/B...0DataSheet.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.
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts