Problem with I2Cread and I2CWRITE function


Closed Thread
Results 1 to 8 of 8
  1. #1
    Tony85's Avatar
    Tony85 Guest

    Default Problem with I2Cread and I2CWRITE function

    Hello,

    I have read MELANIE'S FAQ (I2CRead & I2CWrite not working as expected) but my code always not working. Normaly I must have minute =12 but it give me 0

    I am using 16F877A and 24LC64 (pin1, 2, 3, 4, 7 to the ground ; 8 to 5v ; SDA and SDL to 16F877A).

    Any idea ?

    ---------------------------------------------------
    My code :

    DEFINE OSC 4
    Include "modedefs.bas"
    asm
    ERRORLEVEL -306, -302
    endasm

    DEFINE LCD_DREG PORTD
    DEFINE LCD_RSREG PORTA
    DEFINE LCD_RWREG PORTA
    DEFINE LCD_EREG PORTA
    DEFINE LCD_RSBIT 2
    DEFINE LCD_RWBIT 1
    DEFINE LCD_EBIT 0
    DEFINE LCD_DBIT 0
    DEFINE LCD_BITS 8
    DEFINE LCD_LINES 4

    RETRO VAR PORTA.3
    SCL VAR PORTC.3
    SDA VAR PORTC.4

    minute VAR word
    adr var word

    ADCON1=7
    TRISA=%11100000
    TRISB=%11110000
    TRISD=%11110000

    i2cdevice CON %10100000

    High RETRO

    MAIN:
    adr=1
    I2CWRITE PORTC.4,PORTC.3,i2cdevice,adr,[12]
    pause 10
    i2CREAD PORTC.4,PORTC.3,i2cdevice,adr,[minute]
    pause 10
    LCDOUT $FE,1
    LCDOUT $FE,192,dec minute,"min "
    end

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    Maybe you forgot 2 resistors ?? From SDA to Vcc and SCL to Vcc (4K7)

  3. #3
    Tony85's Avatar
    Tony85 Guest


    Did you find this post helpful? Yes | No

    Default

    Between 16F877 SDA pin and 24LC64 SDA pin I have a 330Ohms resistor and Between 16F877 SCL pin and 24LC64 SCL pin I have a 330Ohms resistor.

  4. #4
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    These are serie resistors, that is no problem. But you must put also 2 resistors from 4K7 to the + power of the PICCHIP and the SDA and SCL line. Kind of pullup resistors.

  5. #5
    Tony85's Avatar
    Tony85 Guest


    Did you find this post helpful? Yes | No

  6. #6
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    You used 10K resistors, lower them to 4K7. And put also a capacitor of 100 nF over each supply point of each ic, near each ic.
    Is your oscillator running well? Because normally I put 22pF capacitors at a 4 MHz cristal.
    Put also an extra elco (10uF) and a capacitor of 330nF near your 7805. This prevents oscillating of this component.

  7. #7
    Tony85's Avatar
    Tony85 Guest


    Did you find this post helpful? Yes | No

    Talking

    I just have put 4.7k resistor and it work good

    Thanks a lot

    Tony

  8. #8
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    You'r welcome.
    M

Similar Threads

  1. I2CRead & I2CWrite not working as expected
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 30
    Last Post: - 27th October 2021, 19:36
  2. Problem with I2Cread and I2CWRITE function
    By Tony85 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th June 2006, 19:32
  3. PFC8583 Connection and I2Cwrite I2cread!
    By uludere72 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 27th February 2006, 14:32
  4. I2CRead / I2CWrite Problem?
    By koossa in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st October 2005, 19:26
  5. I2CWRITE and I2CREAD
    By Tomas in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 23rd April 2004, 03:30

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