PFC8583 Connection and I2Cwrite I2cread!


Closed Thread
Results 1 to 12 of 12
  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
    Dec 2005
    Location
    Corum,Turkiye
    Posts
    15


    Did you find this post helpful? Yes | No

    Default hi Uludere

    i dont understand why it "slow" .. ..
    you write me..

    Hocam merhaba...
    Pcf de sorun yaşamaman lazım.. Ben ikisinide kullandım. ds1307 veya pcf8583 problemsiz entegreler bunlar. bana sıkıntını tam yazarsan yardımcı olabilirim.



    ------------------------------------
    Elektroline
    www.labarna.com
    [email protected]
    ------------------------------------

  8. #8
    Join Date
    Apr 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    thx elektroline!!
    i am going to send my problem on monday !!

  9. #9
    Join Date
    Apr 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default ds1302 AND pfc8583

    pfc 8583 is counting 1 minute in 2 minute ?
    and second is counting to 99?
    Last edited by uludere72; - 24th February 2006 at 20:02.

  10. #10
    Join Date
    Feb 2006
    Posts
    4


    Did you find this post helpful? Yes | No

    Wink Help from Brazil

    Hi, I am a Brazilian Electronic Engineer and my website is www.fdai.net

    I would like to help my friends that have problems with PCF8583 and Melabs PICBasicPRO
    My code for this :
    '************************************************* ***************
    ' PCF 8583 APREDENDO_1.0
    ' programa para testar o chip PCF8583
    ' na placa do Distribuidor de Energia
    ' 26/Fev/2006
    '************************************************* ***************
    define OSC 20
    DEFINE ADC_BITS 10
    define ADC_CLOCK 1
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTD
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTD
    DEFINE LCD_EBIT 3
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    symbol SCL = PORTC.3 ' I2C clock
    symbol SDA = PORTC.5 ' I2C data
    symbol UP = PORTA.4
    SYMBOL DOWN = PORTA.3
    SYMBOL ENTER = PORTA.2
    SYMBOL SEL = PORTA.1
    ;*******************************************
    ; Configuração do PIC
    ;*******************************************
    TRISA=%00111111
    TRISB=%00000000
    TRISC=%00100000
    TRISD=%00000000
    ADCON1 = $0E 'Configura somente RA0 como entrada de AD
    '******************************************
    PORTB=%00000000
    PORTC=%00000000
    PORTD=%00000000
    '*****************************************
    '------------------------
    ' VARIAVEIS DO PROGRAMA
    HOUR VAR BYTE
    MINUTE VAR BYTE
    DAY VAR BYTE
    MONTHY VAR BYTE
    YEAR VAR BYTE
    S VAR BYTE
    M VAR BYTE
    H VAR BYTE
    D var byte
    Mn var byte
    Y var byte
    TEMPO VAR WORD
    '-----------------------
    lcdout $fe,1 'limpa o display
    Pause 500
    lcdout "PCF8583 Aprender"
    Lcdout $fe,$c0
    LCDOUT "FDAI Eletronica"
    Pause 1500
    lcdout $fe,1 'limpa o display
    Pause 100

    Main:
    I2CREAD SDA,SCL,%10100001,2,[S]
    I2CREAD SDA,SCL,%10100001,3,[M]
    I2CREAD SDA,SCL,%10100001,4,[H]
    I2CREAD SDA,SCL,%10100001,5,[D]
    I2CREAD SDA,SCL,%10100001,6,[Mn]
    I2CREAD SDA,SCL,%10100001,7,[Y]

    IF PORTA.1=0 THEN GOSUB ACERTAR

    lcdout $fe,1 'Limpa o LCD
    lcdout $fe,2 'cursor n primeira posição
    lcdout "Hora: ", hex(H),":", hex2(M),":", hex2(S)
    lcdout $fe,$c0 'segunda linha do display
    lcdout "Data: ", hex2(D),".", hex2(Mn),".20",hex2(Y)

    IF PORTA.1=0 THEN GOSUB ACERTAR

    Pause 500
    goto Main 'VOLTA PARA O LOOP PRINCIPAL

    '************************************************* *****************
    ' Rotina de ajuste do relogio RTC
    ACERTAR:
    lcdout $fe,1
    Lcdout "Acertar hora"
    Pause 1000
    TEMPO = 1000
    'Verifica se algum botao de ajuste foi pressionado:
    '------------------------
    VER_BOTOES:

    IF TEMPO =0 THEN
    GOSUB GRAVAR_HORARIO
    RETURN
    ENDIF


    tempo = tempo -1
    ' Checa se algum botao de ajuste de h/min foi pressionado
    If PORTA.3 = 0 Then decmin
    If PORTA.4 = 0 Then incmin ' Last 2 buttons set minute
    If PORTA.1 = 0 Then dechr
    If PORTA.2 = 0 Then inchr ' First 2 buttons set hour
    pause 50
    Goto VER_BOTOES

    '*************************************************
    ' Increment minutes
    incmin: minute = minute + 1
    If minute >= 60 Then
    minute = 0
    Endif
    Goto debounce

    ' Increment hours
    inchr: hour = hour + 1
    If hour >= 24 Then
    hour = 0
    Endif
    Goto debounce

    ' Decrement minutes
    decmin: minute = minute - 1
    If minute >= 60 Then
    minute = 59
    Endif
    Goto debounce

    ' Decrement hours
    dechr: hour = hour - 1
    If hour >= 24 Then
    hour = 23
    Endif
    goto debounce
    '************************************
    'essa é uma parte da rotina de acerto do relogio
    debounce: 'atualiza o relogio na tela na hora do acerto do relogio
    pause 200
    tempo= 90
    lcdout $fe,1
    Lcdout $fe,2
    Lcdout "Acerte Horario:"
    lcdout $fe,$c0
    Lcdout dec2 hour, ":", dec2 minute, ":00"
    goto VER_BOTOES
    '************************************

    '*************************************
    GRAVAR_HORARIO:
    'Converte para Hexadecimal
    DAY = 26
    MONTHY = 4
    YEAR=06

    M = MINUTE/10*16 + MINUTE//10
    H= hour/10*16 + hour//10
    D= DAY/10*16 + DAY//10

    Mn= MONTHY/10*16 + MONTHY//10
    Y = YEAR/10*16 + YEAR//10

    I2cwrite SDA,SCL,%10100001,2,[0]
    I2Cwrite SDA,SCL,%10100001,3,[M]
    I2Cwrite SDA,SCL,%10100001,4,[H]
    I2CWRITE SDA,SCL,%10100001,5,[D]
    I2CWRITE SDA,SCL,%10100001,6,[Mn]
    I2CWRITE SDA,SCL,%10100001,7,[Y]
    RETURN
    '************************************
    End

  11. #11
    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 ...

  12. #12
    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, 14: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