From "Philippe" On Tue, 7 Nov 1995 John.P.Hollingshead@HAPPY.FIRSTNETHOU.COM wrote: > Also, I'm looking for some good sources for the displays. What I > have in mind, is for using a pic 16c57 for taking the 2of 8 binarie > from a cd22202e dtmfdecode chip, and outputing to a serial e-prom and > to output to the display. It then must be able to access the eeprom > to get readback buffers. I already do that, specially to read/write serial EEPROM, I use a 93C46, but another type can also be driven with this code. Here is a piece of code to drive EEPROM ;>>>>>> START OF SAMPLE CODE ; This what I do to drive a PLL MC145170 and a 96C46 EEPROM ;****************************************************************************** ; HCK = PortC.1 ; DATA out = PortC.3 ; DATA in = PortC.5 ; CS PLL = PortC.2 ; CS ROM = PortC.6 ; ;----- PLL & EEPROM Constants bHCK equ 1 PEnb equ 2 REnb equ 6 bDout equ 3 bDin equ 5 bLock equ 0 ;****************************************************************************** ; READ Routine for SERIAL EEPROM (96C46 : 64 X 16Bit) ; REGISTER used: ; Data1 -> $0E ; Data2 -> $0D ; Address/Temp -> $0F ; EETemp -> $0A org $0600 ;76543210 SetDataOut equ %10110001 EERead: movlw SetDataOut ; Set HCK/DOUT/ENB as OUTPUT tris C bcf SPort,bHCK ; bHCK = 0 bcf SPort,REnb ; REnb = 0 ROM ACCESS disable bsf SPort,PEnb ; PEnb = 1 PLL ACCESS disable bcf SPort,bDOUT bsf SPort,REnb nop nop bsf SPort,bHCK nop nop call EEStart movf Temp,W ; GET Address from Temp register andlw %00111111 ; it's a 6 bit ADDRESS iorlw %10000000 ; ADD Read INSTRUCTION to the word call EERdOut call EERdIn movf Data1,W movwf Data2 call EERdIn bcf SPort,REnb ; REnb = 0 ROM ACCESS disable retlw 0 ;--------------- EEStart: bcf SPort,bHCK bsf SPort,Renb bsf SPort,bDOut nop nop nop bsf SPort,bHCK nop nop bcf SPort,bHCK nop retlw 0 ;--------------- EERdOut: bsf SPort,Renb movwf EETemp movlw 8 movwf Temp bcf SPort,bHCK EERdO_1: bcf SPort,bDOut rlf EETemp btfsc STATUS,Cy bsf SPort,bDOut nop nop bsf SPort,bHCK nop nop nop bcf SPort,bHCK decfsz Temp goto EERdO_1 retlw 0 ;--------------- $BREAK EERdIn: bsf SPort,Renb movlw 8 movwf Temp bcf SPort,bHCK EERdI_1: nop nop bsf SPort,bHCK nop bcf STATUS,Cy btfsc SPort,bDIn bsf STATUS,Cy rlf Data1 nop bcf SPort,bHCK decfsz Temp goto EERdI_1 retlw 0 ;****************************************************************************** ;****************************************************************************** ; ENABLE, DISABLE and WRITE Routine for SERIAL EEPROM (64 X 16Bit) ; REGISTER used: ; Data1 -> $0E ; Data2 -> $0D ; Address/Temp -> $0F ; EETemp -> $0A ; CounterA -> $1D ; CounterB -> $1E EEEnable:movlw SetDataOut ; Set HCK/DOUT/ENB as OUTPUT tris C bcf SPort,bHCK ; bHCK = 0 bcf SPort,REnb ; REnb = 0 ROM ACCESS disable bsf SPort,PEnb ; PEnb = 1 PLL ACCESS disable bcf SPort,bDOUT bsf SPort,REnb nop nop bsf SPort,bHCK nop nop bcf SPort,bHCK call EEStart movlw %00110000 ; ENABLE WRITE INSTRUCTION call EERdOut bcf SPort,REnb ; REnb = 0 ROM ACCESS disable retlw 0 EEDisable:movlw SetDataOut ; Set HCK/DOUT/ENB as OUTPUT tris C bcf SPort,bHCK ; bHCK = 0 bcf SPort,REnb ; REnb = 0 ROM ACCESS disable bsf SPort,PEnb ; PEnb = 1 PLL ACCESS disable call EEStart movlw %00000000 ; DISABLE WRITE INSTRUCTION call EERdOut bcf SPort,REnb ; REnb = 0 ROM ACCESS disable retlw 0 EEWrite: movlw SetDataOut ; Set HCK/DOUT/ENB as OUTPUT tris C bcf SPort,bHCK ; bHCK = 0 bcf SPort,REnb ; REnb = 0 ROM ACCESS disable bsf SPort,PEnb ; PEnb = 1 PLL ACCESS disable call EEStart movf Temp,W ; GET Address from Temp register andlw %00111111 ; it's a 5 bit ADDRESS iorlw %01000000 ; ADD WRITE INSTRUCTION to the word call EERdOut movf Data2,W ; Get the "HIGH WORD" call EERdOut movf Data1,W ; Get the "LOW WORD" call EERdOut bcf SPort,REnb ; REnb = 0 ROM ACCESS disable nop ; NOW, waiting for acknowledge bsf SPort,bHCK nop clrf Temp bcf SPort,bHCK nop bsf SPort,REnb movlw MaxWriteTime movwf CounterA EEWait_1:bsf SPort,bHCK nop nop btfsc SPort,bDIn goto EEWait_2 nop bcf SPort,bHCK nop decfsz Temp goto EEWait_1 decfsz CounterA goto EEWait_1 bcf SPort,REnb ; REnb = 0 ROM ACCESS disable retlw 1 ; return "1" there is a problem to write th WORD !!! EEWait_2:bcf SPort,bHCK bcf SPort,REnb ; REnb = 0 ROM ACCESS disable retlw 0 ; return "0", OK. ;>>>>>> END OF SAMPLE CODE