Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Nice I2C asembler routine for PIC16F84A needed

Status
Not open for further replies.

traxonja

Advanced Member level 4
Joined
Apr 6, 2004
Messages
109
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Activity points
1,184
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
 

pic16f84a i2c

Hi

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

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

Trax
 

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.
 

16f i2c

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

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:
**broken link removed**

hope this is useful for you
best regards
 

cardreader with pic16f84

Interface I2C pour microcontrolleur PIC16C84

**broken link removed**

Simple I2C master code for 12-bit series PIC (<=5MHz clock)

**broken link removed**
 

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
 

pic16f84 i2c

traxonja said:
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 ;)
 

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
 


tsa5055 pic

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

I need your help
 

pic16f84 i2c slave basic

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

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
 

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

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

16f84+i2c

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

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)
 

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

67_1184026843_thumb.jpg


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?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top