1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problem in continuous reading data from PCF8563 real time clock

  1. Aug 1, 2013 #1
    ;/**
    ; * EXP 1
    ; *
    ; * This program displays the character '0' on one
    ; * of the seven segment displays.
    ; */

    list p = 18f4520

    include "p18f4520.inc"

    CONFIG OSC = INTIO67
    CONFIG PWRT = ON
    CONFIG WDT = OFF
    CONFIG DEBUG = ON, LVP = OFF

    WriteSlaveAddr EQU b'10100010'
    ReadSlaveAddr EQU b'10100011'
    SecsAddr EQU 0x02
    SecsData EQU b'01010000'
    MinsAddr EQU 0x03
    MinsData EQU b'01011001'
    HoursAddr EQU 0x04
    HoursData EQU b'00000010'

    ORG 0

    start
    clrf TRISC
    bsf TRISC,3
    bsf TRISC,4

    ;/BAUD RATE
    movlw b'00001001'
    movwf SSPADD
    nop
    nop

    ;/SLEW RATE CONTROL
    movlw b'00000000'
    movwf SSPSTAT
    nop
    nop

    ;/ENABLE SERIAL PORT
    movlw b'00101000'
    movwf SSPCON1
    nop
    nop

    ;SET TIME
    call i2c_start
    movlw WriteSlaveAddr
    call i2c_send
    call check_ack
    movlw SecsAddr
    call i2c_send
    call check_ack
    movlw SecsData
    call i2c_send
    call check_ack
    movlw MinsData
    call i2c_send
    call check_ack
    movlw HoursData
    call i2c_send
    call check_ack
    call i2c_restart
    movlw WriteSlaveAddr
    call i2c_send
    call check_ack
    movlw SecsAddr
    call i2c_send
    call check_ack
    call i2c_restart
    movlw ReadSlaveAddr
    call i2c_send
    call receive_mode
    call send_ack
    call i2c_send
    call receive_mode
    call send_ack
    call i2c_send
    call receive_mode
    call send_nack
    call i2c_stop

    ;/START CONDITION
    i2c_start
    bsf SSPCON2,SEN
    call check
    nop
    nop
    return

    ;/I2C SEND
    i2c_send
    movwf SSPBUF
    call check
    nop
    nop
    return

    ;/STOP CONDITION
    i2c_stop
    bsf SSPCON2,PEN
    call check
    nop
    nop
    bz ending
    return

    ;/INTERRUPT
    check
    btfss PIR1,SSPIF
    goto check
    bcf PIR1,SSPIF
    nop
    nop
    return

    check_ack
    btfsc SSPCON2,ACKSTAT
    goto i2c_fail
    nop
    nop
    return

    i2c_restart
    bsf SSPCON2,RSEN
    call check
    nop
    nop
    return

    send_ack
    bcf SSPCON2,ACKDT
    bsf SSPCON2,ACKEN
    call check
    nop
    nop
    return

    send_nack
    bsf SSPCON2,ACKDT
    bsf SSPCON2,ACKEN
    call check
    nop
    nop
    return

    receive_mode
    bsf SSPCON2,RCEN
    call check
    nop
    nop
    return

    i2c_fail
    call i2c_stop

    ending
    bra ending


    END



    Please help me check my code is it have any problems.
     
    Last edited: Aug 1, 2013
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Problem in continuous reading data from PCF8563 real time clock
Loading...