I2CWrite Problem


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,653


    Did you find this post helpful? Yes | No

    Default Re: I2CWrite Problem

    Unfortunately, it never checks the return value so it continues on with the rest of the bytes in the I2CWRITE statement (here you have four of them).
    Not what i find . it may vary by pic18/16 and/or pbp version
    i my test the transaction terminates at the first nak and is followed by a "funny start" dud transaction , the data in the sq brackets is never sent

    Name:  Screenshot 2023-03-19 152852.png
Views: 505
Size:  95.6 KB



    pic18f45k80
    Code:
    'OSCTUNE.6 = 1 ; Enable 4x PLL
    OSCCON = 110000
    
    
    
    
    TRISD=000110 'set PORTD 
    
    
    define OSC 16
    DEFINE I2C_SLOW 1
    ADR VAR BYTE
    ADR2 VAR BYTE
    CMD  VAR BYTE
    ADR=$48
    ADR2=$70   
    
    
    SDA VAR PORTD.3
    SCL VAR PORTD.2
    
    
    
    
    CMD= $48
    
    
    FEDO:
    I2CWRITE SDA,SCL,ADR,[5]
    I2CWRITE SDA,SCL,ADR2,CMD,[3,4]
    PAUSE 250
    I2CWRITE SDA,SCL,ADR,[0]
    I2CWRITE SDA,SCL,ADR2,$48,[2,7]
    PAUSE 250
    GOTO FEDO
    edit
    might be a proteus artifact also, i have not scoped it
    Warning I'm not a teacher

  2. #2
    Join Date
    Aug 2011
    Posts
    455


    Did you find this post helpful? Yes | No

    Default Re: I2CWrite Problem

    That produces a slightly different result, but it's still wrong... there are extra transactions after getting a NACK to the first byte (slave address).
    "S 02 N P" shouldn't be there, and I have a hunch that if you change "ADR2=$70" to something else you'll find that is wrong too.
    I didn't bother trying to figure out exactly what it's sending, but it's not really what's in the remaining I2CWRITE statement.

    I looked at the asm code in both cases and there's nothing I see to look at the ack/nack result of sending a byte, except to send a STOP and reset the internal state so the next byte starts a new transaction. There's nothing to "skip over sending the remaining bytes" in the I2CWRITE.

Similar Threads

  1. problem with I2CWRITE command
    By hatzukitzuki in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 14th October 2010, 22:35
  2. I2CWRITE problem
    By Art in forum mel PIC BASIC Pro
    Replies: 35
    Last Post: - 29th January 2010, 03:01
  3. Problem with I2Cread and I2CWRITE function
    By Tony85 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th June 2006, 20:03
  4. Another I2CWRITE problem
    By ErnieM in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th May 2006, 21:57
  5. I2CRead / I2CWrite Problem?
    By koossa in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st October 2005, 18:26

Members who have read this thread : 0

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