PFC8583 Connection and I2Cwrite I2cread!


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Posts
    32

    Exclamation PFC8583 Connection and I2Cwrite I2cread!

    I want to use PFC8583 . But i coludn't get/set any data .

    I tried

    i2cread sda,scl,$A2,2,[S]
    i2CWrite sda,scl,$A2,4,[H]

    andi changed $A2 =%10100010 ------> %10100001..

    and what must be min configuration for connecting PFC!
    I connected scl and SDA pin!

    ......


    sec var bit

    S var byte
    M var byte
    H var byte

    SCL var PORTB.0
    SDA var PORTA.4
    ....
    .
    .
    .

    '

    Read 4,H
    i2CWrite sda,scl,$A2,4,[H]
    pause 20

    Read 3,M
    i2CWrite sda,scl,$A2,3,[M]
    pause 20

    .
    ...
    call Display_clock
    .



    '''

    Display_Clock:
    toggle sec
    i2cread sda,scl,$A2,2,[S]
    i2cread sda,scl,$A2,3,[M]
    i2cread sda,scl,$A2,4,[H]
    'i2cread sda,scl,$A2,5,[D]
    'i2cread sda,scl,$A2,6,[Mn]
    'i2cread sda,scl,$A2,7,[y]
    LCDout $FE,$C0

    if sec=0 then
    lcdout hex(H),":",hex(M),":",hex(S)

    else
    lcdout hex(H)," ",hex(M)," ",hex(S)
    endif
    return


    thx

  2. #2
    Join Date
    Apr 2005
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    "and what must be min configuration for connecting PFC!
    I connected scl and SDA pin!"


    Did you put two resistors tied to VDD??

    roberto

  3. #3
    Join Date
    Apr 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    i connected resistors..
    i couldn't read and write clock data from PFC?

    ps: i read previous topics but i couldn't find solution ...

  4. #4
    Join Date
    Apr 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    i started to read PFC

    these codes works properly !!

    i2cread sda,scl,$A2,2,[S] 'sec
    i2cread sda,scl,$A2,3,[M] 'minute
    i2cread sda,scl,$A2,4,[H] 'hour

    but i couldn't set time ?

    i want to set "18:59" time to PFC but this code didn't work ?

    ......
    M = 45
    H = 18


    .....
    i2cwrite sda,scl,$A2,2,[S] 'sec
    i2cwrite sda,scl,$A2,3,[M] 'minute
    i2cwrite sda,scl,$A2,4,[H] 'hour

    ....

  5. #5
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    You should use $A1 or $A0 as far as I know...

    Is you control register set to the right value??
    I2CWrite DPIN,CPIN, $A1,$00,[ $09 ] ( See datasheets for the value you need)

  6. #6
    Join Date
    Apr 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    thx!

    i can read and setup time !
    but , clock counts very slow !! I couldnt adjust with variable condansator !!

    please help !!

  7. #7
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    Please give your code... It will be easier to see your problem ...

  8. #8
    Join Date
    Apr 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    here is my PFC code!!
    I solved my problem changin PFC8583 to DS1302 :-)


    Define LOADER_USED 1
    ;Define OSC 20
    Define LCD_DREG PORTD ' Define LCD connections
    Define LCD_DBIT 4
    Define LCD_RSREG PORTE
    Define LCD_RSBIT 0
    Define LCD_EREG PORTE
    Define LCD_EBIT 1



    SCL var PORTC.1
    SDA var PORTC.3

    UP var PORTB.0
    DOWN var PORTB.1



    temp var word
    count_remain var byte
    countPerC var byte

    Menusay var Byte

    LoBATT var byte
    TMP var byte

    sec var bit
    'B0 var byte
    S var byte
    M var byte
    H var byte
    D var byte
    W var byte
    Mn var Byte
    Y var byte
    'ADCON1=7
    'pause 100
    s=0
    M=0
    h=0
    d=0
    W=0
    Mn =0
    Y = 0
    adval var byte ' Create adval to store result


    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %00000100 ' Set PORTA analog

    Low PORTE.2 ' LCD R/W line low (W)
    Pause 100 ' Wait for LCD to start up

    OPTION_REG.7=0 ' pull direncleri aktif
    TRISB=%00001111
    PORTB=0

    ADCON1=7
    pause 100
    I2Cwrite SDA,SCL,$A2,2,[S,m,h,d,W,MN,Y]
    pause 50
    main:

    ' goto main



    'Lcdout $fe, 1 ' Clear screen
    Lcdout $fe, 1 ,"Clock" ' Clear screen
    pause 1000
    TRISA=%00001110 ' port a 0 cıkıs 1 giris yapıldı
    LOW PortA.0
    menusay=0
    mainloop:

    if UP = 0 then
    pause 50
    IF MenuSay < 3 then
    Menusay = Menusay+1
    Lcdout $fe, 1,"MENU", dec menusay
    pause 500

    Gosub SetupMenu
    else
    menusay=0
    endif
    endif





    if menusay = 0 then
    GOsub SAAT

    endif





    Goto mainloop ' Do it all forever



    ''' SAAT RUTINI

    SAAT:
    ' Lcdout $fe, 1, " OKUNUYOR"
    ' pause 1000
    toggle sec




    i2cread sda,scl,$A1,2,[S] 'sn
    i2cread sda,scl,$A1,3,[M] 'dakika
    i2cread sda,scl,$A1,4,[H] 'saat

    '


    Lcdout $fe, $c0,"Saat:",hex2 (H),":",hex2( M),":",Hex2 (S )
    pause 250
    return


    SetupMenu:

    Select Case MenuSay

    'Case 1; Baslangis sicakligi


    case 1 ; Saat Ayar

    DevamSaat:
    'Read 4,H ' epprom 1
    'Lcdout $fe, 1,"S :" ,Dec (H)

    ' call RTC_write


    Gosub ArtirAzalt
    IF up = 0 and down=0 then goto CikisSaat
    goto DevamSaat
    cikisSaat:
    Lcdout $fe, 1,"SET :S:" ,Dec (H)

    'gosub RTCWrite
    I2Cwrite SDA,SCL,$A1,4,[h]
    pause 250


    case 2 ; dakika ayar
    DevamDakika:


    Gosub ArtirAzalt
    ' i2CWrite sda,scl,$A2,3,[M] 'saat
    '

    IF up = 0 and down = 0 then goto CikisDakika

    goto DevamDakika
    cikisDakika:
    Lcdout $fe, 1,"Dk Set"
    'gosub rtcWrite
    I2Cwrite SDA,SCL,$A1,3,[m]
    pause 250
    'Case 4 ; Gun Ayarla

    'Case 5 ; Ay ayarla
    Case 3 ;save
    Lcdout $fe, 1,"Setup OK"
    pause 1000
    menusay = 0

    end select

    Return
    ;????????????????????????????????????????????????? ????????????????????????


    ;Azaltma Artirma Rutinleri
    ArtirAzalt:

    ;Sıcalik Artir
    Select Case Menusay

    case 1 ' Saat
    if up = 0 then
    pause 50
    if H = 23 then
    H =0
    else
    H = H + 1
    endif
    endif
    If Down = 0 then
    pause 50
    if H = 0 then
    H = 23
    else
    H = H -1
    Endif
    endif
    Lcdout $fe, 1,"Saat", dec H
    pause 250

    case 2 ' Dakika
    if up=0 then
    pause 50
    if m = 59 then
    m =0
    else
    m = m + 1
    endif
    endif

    If Down = 0 then
    pause 50
    if M = 0 then
    M = 59
    else
    m = m -1
    Endif
    endif
    Lcdout $fe, 1,"Dakika", dec M
    pause 250
    end select
    Return



    RTCWrite:

    tmp=S
    S=(tmp dig 1<<4)+(tmp dig 0)
    tmp=M
    M=(tmp dig 1<<4)+(tmp dig 0)
    tmp=H
    H=(tmp dig 1<<4)+(tmp dig 0)
    tmp=D
    D=(tmp dig 1<<4)+(tmp dig 0)
    tmp=MN
    MN=(tmp dig 1<<4)+(tmp dig 0)
    tmp=Y
    Y=(tmp dig 1<<4)+(tmp dig 0)

    I2CWRITE SDA,SCL,$A1,2,[S,M,H,D,W,MN,Y] 'Write parameters to RTC
    pause 50
    return

    end

Similar Threads

  1. PIC 18F4550 and MCP23017
    By DaveC3 in forum Code Examples
    Replies: 12
    Last Post: - 4th December 2010, 15:01

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