This is a multi-part message in MIME format. ------=_NextPart_000_3202_7b6f_f87 Content-Type: text/plain; charset=iso-8859-1; format=flowed Acabei encontrando um arquivo e selecionei algumas rotinas que lhe serco zteis >From: egnascimento@YAHOO.COM.BR >Reply-To: pic microcontroller discussion list >To: PICLIST@MITVMA.MIT.EDU >Subject: [PIC:] Interface between PIC and PCF8583 >Date: Thu, 22 Apr 2004 16:27:10 -0300 > >Hi all, > Can anybody recommend me a example or source code of a PIC >communicating >with a I2C real time clock. This is the first time that I work with it and >don't know what to do. > >Thanks in advance, >Edu > > >--- >Outgoing mail is certified Virus Free. >Checked by AVG anti-virus system (http://www.grisoft.com). >Version: 6.0.665 / Virus Database: 428 - Release Date: 21/04/04 > >-- >http://www.piclist.com hint: The list server can filter out subtopics >(like ads or off topics) for you. See http://www.piclist.com/#topics _________________________________________________________________ MSN Hotmail, o maior webmail do Brasil. http://www.hotmail.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details. ------=_NextPart_000_3202_7b6f_f87 Content-Type: text/plain; name="PCF8583.txt"; format=flowed Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="PCF8583.txt" ;-------RxBytePCF --------------------------------------------- ;Rotina para receber um byte do barramento ;-------------------------------------------------------------- RxBytePCF bsf STATUS,RP0 bsf TRISB,2 bcf STATUS,RP0 clrf DadoMemo movlw 0x08 movwf ContaPulso bsf SCL NOP NOP btfsc PORTB,2 bsf DadoMemo,7 rlf DadoMemo bcf SCL decfsz ContaPulso goto $-8 rlf DadoMemo bsf STATUS,RP0 movlw 0xFB andwf TRISB,1 bcf STATUS,RP0 bsf SDA ;Ack call Dlay5u ; bsf SCL ; call Dlay5u ; bcf SCL ; return ;-------EscritaPCF----------------------------------------------- ;Rotina para escrever um byte alocado no Registro DadoMemo ;na Posigao de Memsria do PCF. O enderego da Posigao de Memsria ;deve estar no Registro PosiMemo ;---------------------------------------------------------------- EscritaPCF bsf SDA bsf SCL call Dlay5u bcf SDA ;Bit de start call Dlay5u ; bcf SCL ; movlw 0xA0 ;Enderego do Relsgio call TxBytePCF ; movf PosiMemo,0 ;Enderego do Registro a ser escrito call TxBytePCF ; movf DadoMemo,0 ;Dado a ser escrito no Registro call TxBytePCF ; bcf SDA bsf SCL ;Bit de stop call Dlay5u ; bsf SDA ; return ;-------LeituraPCF ----------------------------------------------- ;Rotina para Leitura de um byte da Posigao de Memsria do PCF(Registrado em PosiMemo) ;e alocagco desse valor no Registro DadoMemo ;----------------------------------------------------------------- LeituraPCF bsf SDA bsf SCL call Dlay5u bcf SDA ;Bit de start call Dlay5u ; bcf SCL ; movlw 0xA0 ;Enderego do PCF call TxBytePCF ; movf PosiMemo,0 ;Enderego do Registro do PCF a ser lido call TxBytePCF ; bsf SDA bsf SCL call Dlay5u bcf SDA ;Bit de start call Dlay5u ; bcf SCL ; movlw 0xA1 ;Indica leitura do PCF call TxBytePCF ; call RxBytePCF ;O Dado lido estara disponmvel no registro DadoMemo bcf SDA ; bsf SCL ;Bit de stop call Dlay5u ; bsf SDA ; return ;------------------------LerDataHora----------------------- ;Rotina que Lj e escreve a Data e Hora no LCD ;--------------------------------------------------------- LerDataHora swapf DadoMemo,0 ; andlw 0x0F ; addlw 0x30 ; bsf Controle,5 ; call EnviaInstru ; movf DadoMemo,0 ; andlw 0xF ; addlw 0x30 ; bsf Controle,5 ; call EnviaInstru ; return ;------------------------EscreveData----------------------- ;Rotina que Lj e escreve a Data no LCD ;--------------------------------------------------------- EscreveData movlw 0x80 ;Para a contagem do PCF movwf DadoMemo ; clrf PosiMemo ; call EscritaPCF ; movlw 0x05 ;Lj o Registro 05 do PCF movwf PosiMemo ; call LeituraPCF ; bcf DadoMemo,7 ; bcf DadoMemo,6 ; call LerDataHora ; bsf Controle,5 ; call EnviaControle ; movlw 0x2F ;Escreve o "/" call EnviaInstru ; movlw 0x06 ; movwf PosiMemo ; call LeituraPCF ; bcf DadoMemo,7 ; bcf DadoMemo,6 ; bcf DadoMemo,5 ; call LerDataHora ; clrf DadoMemo ;Reinicia a contagem do PCF clrf PosiMemo ; call EscritaPCF ; return -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details. ------=_NextPart_000_3202_7b6f_f87--