---
+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 20 of 22
  1. #1
    Full Member level 1
    Points: 3,016, Level: 12

    Join Date
    Apr 2004
    Posts
    109
    Helped
    2 / 2
    Points
    3,016
    Level
    12

    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
    SIGNATURE LINKS ARE NOT ALLOWED

  2. #2
    Member level 2
    Points: 2,771, Level: 12

    Join Date
    Mar 2004
    Location
    Australia
    Posts
    48
    Helped
    4 / 4
    Points
    2,771
    Level
    12

    pic16f84a i2c

    Hi

    is what the device that u have a smartcard (gold wafer) caus that cojntains the 2 ICs u talking about.


    2 members found this post helpful.

  3. #3
    Full Member level 1
    Points: 3,016, Level: 12

    Join Date
    Apr 2004
    Posts
    109
    Helped
    2 / 2
    Points
    3,016
    Level
    12

    i2c pic16f84a

    No, it's only my PIC and some eeprom, in my case it is 24c16.

    Trax
    SIGNATURE LINKS ARE NOT ALLOWED



  4. #4
    Advanced Member level 4
    Points: 19,442, Level: 33
    Kripton2035's Avatar
    Join Date
    Jul 2001
    Location
    Western Europe
    Posts
    1,052
    Helped
    169 / 169
    Points
    19,442
    Level
    33

    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.



  5. #5
    Full Member level 1
    Points: 2,789, Level: 12

    Join Date
    Apr 2002
    Location
    POLAND
    Posts
    111
    Helped
    0 / 0
    Points
    2,789
    Level
    12

    pic i2c asm

    Look at www.piclist.com huge library of source codes and clues sorted in categories.



    •   Alt19th April 2004, 14:54

      advertising

        
       

  6. #6
    Member level 4
    Points: 2,753, Level: 12

    Join Date
    Jun 2003
    Location
    sharjah
    Posts
    69
    Helped
    4 / 4
    Points
    2,753
    Level
    12

    16f i2c

    hi,
    check out the routines provided by microchip itself, they work fine to my knowleded!!
    cheers
    sam



    •   Alt19th April 2004, 15:04

      advertising

        
       

  7. #7
    Advanced Member level 4
    Points: 11,937, Level: 26

    Join Date
    Jul 2001
    Posts
    1,060
    Helped
    92 / 92
    Points
    11,937
    Level
    26

    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



  8. #8
    Full Member level 6
    Points: 5,199, Level: 17

    Join Date
    Jun 2002
    Posts
    383
    Helped
    15 / 15
    Points
    5,199
    Level
    17

    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



    •   Alt19th April 2004, 16:23

      advertising

        
       

  9. #9
    Full Member level 1
    Points: 3,016, Level: 12

    Join Date
    Apr 2004
    Posts
    109
    Helped
    2 / 2
    Points
    3,016
    Level
    12

    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
    SIGNATURE LINKS ARE NOT ALLOWED



  10. #10
    Full Member level 1
    Points: 2,789, Level: 12

    Join Date
    Apr 2002
    Location
    POLAND
    Posts
    111
    Helped
    0 / 0
    Points
    2,789
    Level
    12

    pic16f84 i2c

    Quote Originally Posted by traxonja
    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 ;)



  11. #11
    Full Member level 5
    Points: 5,563, Level: 17

    Join Date
    May 2002
    Location
    from istanbul in TURKEY
    Posts
    289
    Helped
    11 / 11
    Points
    5,563
    Level
    17

    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



  12. #12
    Full Member level 6
    Points: 5,199, Level: 17

    Join Date
    Jun 2002
    Posts
    383
    Helped
    15 / 15
    Points
    5,199
    Level
    17

    tsa5055.asm

    Copieur autonome de mmoires 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



  13. #13
    Full Member level 4
    Points: 2,664, Level: 12

    Join Date
    Jan 2005
    Posts
    204
    Helped
    9 / 9
    Points
    2,664
    Level
    12

    tsa5055 pic

    I want a clear program for just reading and writing in serial eeprom like 24C64 with 16f84.

    I need your help



  14. #14
    Newbie level 1
    Points: 1,026, Level: 7

    Join Date
    Mar 2007
    Posts
    1
    Helped
    0 / 0
    Points
    1,026
    Level
    7

    pic16f84 i2c slave basic

    does anyone have an exe file to comunicate with the 16f84 serial out?
    pls?
    ty for ure kindnes



  15. #15
    Junior Member level 3
    Points: 1,236, Level: 7

    Join Date
    Mar 2007
    Location
    bulgaria
    Posts
    25
    Helped
    4 / 4
    Points
    1,236
    Level
    7

    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



  16. #16
    Junior Member level 1
    Points: 1,144, Level: 7

    Join Date
    Feb 2007
    Posts
    14
    Helped
    5 / 5
    Points
    1,144
    Level
    7

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



  17. #17
    Member level 2
    Points: 2,771, Level: 12

    Join Date
    Mar 2004
    Location
    Australia
    Posts
    48
    Helped
    4 / 4
    Points
    2,771
    Level
    12

    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
    :)



  18. #18
    Junior Member level 1
    Points: 1,144, Level: 7

    Join Date
    Feb 2007
    Posts
    14
    Helped
    5 / 5
    Points
    1,144
    Level
    7

    16f84+i2c

    is there any sample code that used to write gold wafer card?



  19. #19
    Member level 2
    Points: 2,771, Level: 12

    Join Date
    Mar 2004
    Location
    Australia
    Posts
    48
    Helped
    4 / 4
    Points
    2,771
    Level
    12

    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)



  20. #20
    Junior Member level 1
    Points: 1,144, Level: 7

    Join Date
    Feb 2007
    Posts
    14
    Helped
    5 / 5
    Points
    1,144
    Level
    7

    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?



+ Post New Thread
Please login
Page 1 of 2 12 LastLast