problems with I2C.... and ideas why dosent work?


Results 1 to 26 of 26

Threaded View

  1. #1
    snood's Avatar
    snood Guest

    Default problems with I2C.... and ideas why dosent work?

    okay, i'm using a PIC16F876A and a DS1307 RTC, i have written a short program which should set the time, then loop reading the time to confirm that it is infact set. the problem is when i go to run this in the device... the LCD screen just shows up values with everything reading "00". this to me suggests that i have something wrong with the write commands. here's the offending code:


    TRISC = %11111111
    TRISB = %11111111

    second var byte
    minute var byte
    hour var byte
    day var byte
    date var byte
    month var byte
    year var byte

    ITCDEVICE var byte
    ITCADDRESS var byte

    SDA var PORTC.4
    CLK Var PORTC.3

    LCDOUT var PORTB.0

    ITCDEVICE = $D0
    ITCADDRESS = $00

    second = 0
    minute = 0
    hour = 12
    day = 2
    date = 25
    year = 5

    pause 1000

    I2CWRITE SDA, CLK, ITCDEVICE, ITCADDRESS, [second, minute, hour, day, date, year]

    second = 255 'change variables to make sure it recieves correctly'
    minute = 255
    hour = 255
    day = 255
    date = 255
    year = 255

    loop:

    pause 500

    I2CREAD SDA, CLK, ITCDEVICE, ITCADDRESS, [second, minute, hour, day, date, year]

    serout LCDout, 6,[254,1] 'clears screen'
    serout LCDout, 6,[254,128] 'sets position'
    serout LCDout, 6,[#hour,":",#minute,":",#second] 'displays the read time
    serout LCDout, 6,[254,192] 'next line'
    serout LCDout, 6,["month:",#month," year:",#year] 'displays the read date

    goto loop
    Last edited by snood; - 23rd April 2005 at 16:06.

Similar Threads

  1. I2C problems
    By Mad_Labs in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 25th September 2005, 05:22

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