| Author |
Message |
traxonja
Joined: 06 Apr 2004 Posts: 109 Helped: 1
|
18 Apr 2004 19:27 i2c pic16f84 |
|
|
|
|
Hello,
does anybody have a nice (clean) routine for writing and reading-from an I2C memory device written for MPASM?
I will use PIC16F84A, and 24LC16 (2k) device so 1-byte address will be used, but 2-byte addresses are OK too.
I have this attached routine but it doesn't work , so if you have a nice tested one please post it here.
When I programm the device in PicBasic, it works, but with this routine in MPASM it doesn't work
All best,
Trax
|
|
| Back to top |
|
 |
Google AdSense

|
18 Apr 2004 19:27 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
zmanultra
Joined: 20 Mar 2004 Posts: 48 Helped: 2 Location: Australia
|
19 Apr 2004 2:30 pic16f84a i2c |
|
|
|
|
Hi
is what the device that u have a smartcard (gold wafer) caus that cojntains the 2 ICs u talking about.
|
|
| Back to top |
|
 |
traxonja
Joined: 06 Apr 2004 Posts: 109 Helped: 1
|
19 Apr 2004 9:38 i2c pic16f84a |
|
|
|
|
No, it's only my PIC and some eeprom, in my case it is 24c16.
Trax
|
|
| Back to top |
|
 |
Kripton2035
Joined: 19 Jul 2001 Posts: 611 Helped: 21 Location: Earth
|
19 Apr 2004 14:34 i2c assembler |
|
|
|
|
be aware that if you look at the details of the picbasic language, the i2c routines works well only with hard i2c chips for example 16f876, but not the 16f84...
they work quite in master mode, but quite not in slave.
|
|
| Back to top |
|
 |
elektryk
Joined: 25 Apr 2002 Posts: 117 Location: POLAND
|
19 Apr 2004 14:54 pic i2c asm |
|
|
|
|
| Look at www.piclist.com huge library of source codes and clues sorted in categories.
|
|
| Back to top |
|
 |
sam_manchali
Joined: 14 Jun 2003 Posts: 105 Helped: 3 Location: sharjah
|
19 Apr 2004 15:04 16f i2c |
|
|
|
|
hi,
check out the routines provided by microchip itself, they work fine to my knowleded!!
cheers
sam
|
|
| Back to top |
|
 |
C-Man
Joined: 19 Jul 2001 Posts: 1236 Helped: 73
|
19 Apr 2004 15:10 16f84 i2c |
|
|
|
|
traxonja
a few years ago i programmed a project in PIC assembler which was storing data from a magnetic card reader in a 24C16 using a 16F84.
I have posted the source here:
http://www.elektroda.pl/eboard/searchtopic66923-.html
hope this is useful for you
best regards
|
|
| Back to top |
|
 |
elcielo
Joined: 13 Jun 2002 Posts: 854 Helped: 6
|
19 Apr 2004 16:23 cardreader with pic16f84 |
|
|
|
|
Interface I2C pour microcontrolleur PIC16C84
http://perso.easynet.fr/~chrisg/pici2c.htm
Simple I2C master code for 12-bit series PIC (<=5MHz clock)
http://www.kingswood-consulting.co.uk/pic/i2c.i
|
|
| Back to top |
|
 |
traxonja
Joined: 06 Apr 2004 Posts: 109 Helped: 1
|
19 Apr 2004 20:04 pic16f84a+24c01 |
|
|
|
|
Thanks for the answers. I found a nice routine at www.piclist.com.
And, I couldn't download a file from this forum because I am stil a new user and I don't have any points
Best regards,
Trax
|
|
| Back to top |
|
 |
elektryk
Joined: 25 Apr 2002 Posts: 117 Location: POLAND
|
23 Apr 2004 14:52 pic16f84 i2c |
|
|
|
|
| traxonja wrote: |
And, I couldn't download a file from this forum because I am stil a new user and I don't have any points |
You have now
|
|
| Back to top |
|
 |
mbyka
Joined: 12 May 2002 Posts: 510 Helped: 1
|
23 Apr 2004 22:14 pic16f84 magnetic card reader |
|
|
|
|
Hi
I can help you with my sample code
maybe
| Code: |
LIST P=16F84
INCLUDE "P16F84.inc"
TITLE " 24Cxx Programming with pic"
EEPROM EQU 1CH
ADDR EQU 1DH
DATAI EQU 1EH
DATAO EQU 1FH
TXBUF EQU 20H
RXBUF EQU 21H
COUNT EQU 22H
DEL EQU 23H
SEL EQU 24H
DI EQU 7
DO EQU 6
SDA EQU 1
SCL EQU 0
;PortA.0--------->Serial Clock----------24Cxx's Pin:6
;PortA.1<-------->Serial Data-----------24Cxx's Pin:5
;PortB LED outs
__CONFIG _WDT_OFF & _XT_OSC & _CP_OFF
;====================================================
;========= start======================
ORG 000H
GOTO START
START
CALL PORT_INIT
MAIN
MOVLW 00H ;Eeprom write Adress
MOVWF ADDR
MOVLW 23H ;Eeprom data
MOVWF DATAO
CALL WRITE_EEPROM
MOVLW .100
CALL DELAY_NMS
MOVLW 00H ;Eeprom read adress
MOVWF ADDR
CALL READ_EEPROM
MOVF DATAI,W
MOVWF PORTB ;read from Eeprom transfer data portb
MOVLW .100
CALL DELAY_NMS
DONE
GOTO DONE
;========================================================
;================= Port Init ============================
PORT_INIT
CLRF PORTA
CLRF PORTB
;
BSF STATUS, RP0 ;page1 select
CLRF TRISA
CLRF TRISB
BCF STATUS, RP0 ;page0 select
;
CLRF PORTB
RETURN
;=============================================================
;======== eeprom cominication=========================
WRITE_EEPROM
CALL BSTART
;
MOVLW B'10100000'
MOVWF TXBUF
CALL TX
;
MOVF ADDR,W
MOVWF TXBUF
CALL TX
;
MOVF DATAO,W
MOVWF TXBUF
CALL TX
;
CALL BSTOP
;
RETURN
READ_EEPROM
CALL BSTART
;
MOVLW B'10100000'
MOVWF TXBUF
CALL TX
;
MOVF ADDR,W
MOVWF TXBUF
CALL TX
;
CALL BSTART
;
MOVLW B'10100001'
MOVWF TXBUF
CALL TX
;
CALL RX
;
CALL BSTOP
;
RETURN
BSTART
BSF PORTA,SDA
BSF STATUS, RP0
MOVLW 00H
MOVWF TRISA
BCF STATUS, RP0
;
BCF PORTA,SCL
NOP
BSF PORTA,SCL
NOP
NOP
NOP
NOP
NOP
BCF PORTA,SDA
NOP
NOP
NOP
NOP
NOP
BCF PORTA,SCL
NOP
NOP
RETURN
BSTOP
BSF STATUS, RP0
MOVLW 00H
MOVWF TRISA
BCF STATUS, RP0
;
BCF PORTA,SDA
NOP
NOP
NOP
BSF PORTA,SCL
NOP
NOP
NOP
BSF PORTA,SDA
NOP
NOP
BCF PORTA,SCL
NOP
NOP
NOP
RETURN
BITOUT
BSF STATUS, RP0
MOVLW 00H
MOVWF TRISA
BCF STATUS, RP0
;
BTFSS EEPROM,DO
GOTO BITLOW
BSF PORTA,SDA
GOTO CLK_OUT
BITLOW
BCF PORTA,SDA
CLK_OUT
BSF PORTA,SCL
NOP
NOP
NOP
NOP
BCF PORTA,SCL
NOP
RETURN
BITIN
BSF EEPROM,DI
;
BSF STATUS,RP0
MOVLW 02H
MOVWF TRISA
BCF STATUS, RP0
;
BSF PORTA,SCL
NOP
NOP
NOP
NOP
NOP
BTFSS PORTA,SDA
BCF EEPROM,DI
BCF PORTA,SCL
RETURN
TX
MOVLW .8
MOVWF COUNT
TXLP
BCF EEPROM,DO
BTFSC TXBUF,7
BSF EEPROM,DO
CALL BITOUT
RLF TXBUF,F
DECFSZ COUNT,F
GOTO TXLP
CALL BITIN
RETURN
RX
CLRF DATAI
MOVLW .8
MOVWF COUNT
BCF STATUS,0
RXLP
RLF DATAI,F
CALL BITIN
BTFSC EEPROM,DI
BSF DATAI,0
DECFSZ COUNT,F
GOTO RXLP
BSF EEPROM,DO
CALL BITOUT
RETURN
DELAY_NMS
MOVWF DEL
OUTTER_MS
MOVLW .110
MOVWF SEL
INNER_MS
NOP
NOP
NOP
NOP
NOP
NOP
DECFSZ SEL,F
GOTO INNER_MS
DECFSZ DEL,F
GOTO OUTTER_MS
RETURN
END
|
|
|
| Back to top |
|
 |
elcielo
Joined: 13 Jun 2002 Posts: 854 Helped: 6
|
29 Apr 2004 23:50 tsa5055.asm |
|
|
|
|
Copieur autonome de mémoires I2C 24C01 à 24C16
http://col2000.free.fr/copieur/cop_indx.htm
I2C-Programm fuer 2,65GHz-PLL-IC TSA5055 for PIC 16F84(A)
http://www.qsl.net/db0mwb/projekte/tsa5055.asm
PIC 16F84 - TIMER PCF8583 - EEPROM 24LC65, COMMUNICATION I2C ET AFFICHEUR LCD LTN211
http://www.asmfr.com/code.aspx?ID=15193
BUS I2C POUR PIC16XXX
http://www.asmfr.com/listecodes.aspx?catid=261
Couplage PIC16F84 & 24C16
http://col2000.free.fr/i2c/protocol/eeprom05.asm
|
|
| Back to top |
|
 |
hassan1980
Joined: 14 Jan 2005 Posts: 210 Helped: 3
|
07 Feb 2005 21:44 tsa5055 pic |
|
|
|
|
I want a clear program for just reading and writing in serial eeprom like 24C64 with 16f84.
I need your help
|
|
| Back to top |
|
 |
dragosdiaconita
Joined: 22 Mar 2007 Posts: 1
|
22 Mar 2007 17:04 pic16f84 i2c slave basic |
|
|
|
|
does anyone have an exe file to comunicate with the 16f84 serial out?
pls?
ty for ure kindnes
|
|
| Back to top |
|
 |
tonybg
Joined: 17 Mar 2007 Posts: 18 Helped: 2 Location: bulgaria
|
22 Mar 2007 17:43 pic16f84 read 24c01 eeprom |
|
|
|
|
| Why don't you try Application Maestro.It's a part of MPLAB.Generates many protocols,and explains all the details about hardware and software on the specfic code it generates.Hope it helped:D
|
|
| Back to top |
|
 |
iman_andeh
Joined: 19 Feb 2007 Posts: 16 Helped: 1
|
09 Jul 2007 4:41 i2c pic16f |
|
|
|
|
how to communicate (read and write) the gold wafer card using other PIC mcu such as PIC16F877A?
i'm trying to build a portable gold wafer card reader/writer...
|
|
| Back to top |
|
 |
zmanultra
Joined: 20 Mar 2004 Posts: 48 Helped: 2 Location: Australia
|
09 Jul 2007 4:45 i2c with pic16f84a |
|
|
|
|
its like programming a normal pic processor....the only difference is that u must creat a serial Comm routine...check out picbasic pro...it has some serial routines...thats the easiest way....or u can use microchip compiler....
hope this helps
|
|
| Back to top |
|
 |
iman_andeh
Joined: 19 Feb 2007 Posts: 16 Helped: 1
|
09 Jul 2007 23:58 16f84+i2c |
|
|
|
|
| is there any sample code that used to write gold wafer card?
|
|
| Back to top |
|
 |
zmanultra
Joined: 20 Mar 2004 Posts: 48 Helped: 2 Location: Australia
|
10 Jul 2007 0:23 master i2c for pic16f690 |
|
|
|
|
| dont worry about "gold wafer card" look at it as simply programming a chip....(pic16) have u programed that chip b4....if not, just have a look at the sample code provided (e.g. pic basic is good for beginers)
|
|
| Back to top |
|
 |
iman_andeh
Joined: 19 Feb 2007 Posts: 16 Helped: 1
|
10 Jul 2007 1:26 pic16f84a mit i²c |
|
|
|
|
yes, i have programmed PIC before, that is PIC16F877a..
about gold wafer card,
i'm really confused what i should do now.
i tend to use circuit below as my gold wafer card reader and programmer
this circuit was grabbed from Silicon Chip (issue 178 (July 15, 2003), by Peter Smith)
but,
i really have no idea about the code. could you give an example code?
|
|
| Back to top |
|
 |
zmanultra
Joined: 20 Mar 2004 Posts: 48 Helped: 2 Location: Australia
|
10 Jul 2007 1:34 i2c pic16f84 meppel |
|
|
|
|
i have programmed the exact same card b4...
the steps to go on about it.
for testing...
(write a serial routine which just outputs a letter every second or somthing...(in pic basic pro its just 2 lines of code...check it out) and then get a software (google it up) to monitor the serial port and have a look at the card(pic processor) is outputing.....
and then u should have a clearer pic of wat the hell is going on
hope this is helping u dude?
|
|
| Back to top |
|
 |
hulahula
Joined: 15 Jul 2006 Posts: 33
|
10 Jul 2007 2:09 pic16f 628 card reader |
|
|
|
|
| http://www.c51c51.com/index.php?lay=show&ac=webboard
|
|
| Back to top |
|
 |