Problems Communicating to VCNL4040


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Mar 2016
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: Problems Communicating to VCNL4040

    Well I figured out the I2Creadfor the initialization. The slave address byte should be: %11000000 and not %01100000. So good but no matter what register I read from ($00 to $0C) I get zeros. I think I know the problem but don't have a fix. From research I understand that the VCNL4040 can't have a stop bit from the master
    between a I2CWRITE & I2CREAD. So when I switch from a write to a read (as shown below) I get zeros from $08 register.

    I2Cwrite PORTC.4,PORTC.3,%11000000,%00001000 '$08
    pause 5

    I2Cread PORTC.4,PORTC.3,%11000000,[PS_DATA_L,PS_DATA_H]
    PAUSE 5

    The data sheet shows this format to read register $08 instead of just a I2CREAD. There fore when the I2CWRITE finishes I get a stop bit from master and the data sheet shows to use no stop from master between the Write & READ.

    Any ideas how to get around this with out writing my own I2C statement?

    Thanks

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: Problems Communicating to VCNL4040

    DEVICE_ID VAR WORD
    VCNL4040_addr VAR BYTE
    REG_ADDR VAR BYTE
    VCNL4040_addr=$C0
    REG_ADDR= $0C



    I2Cread PORTC.4,PORTC.3,VCNL4040_addr,REG_ADDR,[DEVICE_ID]
    Warning I'm not a teacher

Similar Threads

  1. Communicating 2 x-10 transceiver
    By snoopy in forum Schematics
    Replies: 1
    Last Post: - 7th May 2011, 17:10
  2. Communicating between two PICs over DC bus
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th May 2009, 12:57
  3. communicating pic18f452 with pic16f877a
    By tamersoss in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th July 2007, 19:54
  4. Replies: 13
    Last Post: - 22nd November 2006, 08:00
  5. Communicating from one micro to another??
    By jblackann in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th October 2006, 02:53

Members who have read this thread : 2

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