Hi all, I have worked on a very similar interface recently and am happy to hand over tested proven code that works with four mc14094 8bit shift/store registers. Just chip select, clock in data, and strobe to set register outputs. The 4094 o/p stay as they are until new data is clocked in and strobed. Any probs mail me back. Hope code is self explanitory. Regards, Roger Melton Perth WA Australia rjmwa@hotmail.com ;************************************************************************ ; * ; THIS IS THE SECTION OF CODE THAT READS DATA FROM RAM AND DISPLAY* ; ON TO 4 DIGIT LCD (4094 * 4) .DATA IS 4 BYTES STARTING FROM * ; DATA AREA STATED BY DISPLYWD. * ; * ;************************************************************************ ;BYTEOUT ;LCD_COUNT LCD_START CALL LCD_INIT LCD_OUT MOVWF BYTEOUT ;W TO WORD FOR TX CALL DATASEND ;SEND DIGIT OUT INCF FSR,1 MOVF INDF,0 ;NEXT DATA ADDR TO W DECFSZ LCD_BYTECNT,1 GOTO LCD_OUT CALL STROBE ;STROBE LATCHES CALL LCD_INIT LCD_INVOUT MOVWF BYTEOUT ;W TO WORD FOR TX CALL INVERT CALL DATASEND ;SEND DIGIT OUT INCF FSR,1 MOVF INDF,0 ;NEXT DATA ADDR TO W DECFSZ LCD_BYTECNT,1 GOTO LCD_OUT CALL STROBE ;STROBE LATCHES ;********************************************************************** LCD_INIT MOVLW 4 ;COUNT 4 WORDS MOVWF LCD_BYTECNT ;LOAD COUNTER MOVLW DISPLYWD ;DATA STORE FOR DISP DATA MOVWF FSR ;SET FSR TO DATA ADDR MOVF INDF,0 ;FIRST DATA ADDR TO W ;************************************************************************ ; THIS CODE SENDS OUT DATA IN BYTEOUT DATASEND MOVLW D'8' ;8 BITS TO SEND MOVWF LCD_COUNT ; LOOP BCF PORTB,CLK_LINE ;CLEAR CLOCK LINE LAST DATA BIT CLK'ED OUT RLF BYTEOUT,1 ;SHIFT DATA LEFT (MSB FIRST) TO CARRY FLAG BTFSC STATUS,C ;SKIP IF LOW BSF PORTB,DATA_LINE ;DATA IS SET HIGH BTFSS STATUS,C ;SKIP IF HIGH BCF PORTB,DATA_LINE ;DATA IS SET LOW NOP BSF PORTB,CLK_LINE ;CLOCK LINE HIGH(DATA SHIFTS ON POS TRANSITION) NOP BCF PORTB,CLK_LINE ;CLEAR CLOCK LINE LAST DATA BIT CLK'ED OUT DECFSZ LCD_COUNT,1 ;HAS ALL BITS BEEN SENT YET GOTO LOOP ;IF NOT SEND NEXT BIT RETURN ;********************************************************************** DELAY ;DELAY ROUTINE DECFSZ DELCNT,1 ;DEC DELCNT SKP=0 GOTO DELAY ;IF >0 DEC AGAIN MOVLW 0XFF ;REPLACE INITIAL SETTING MOVWF DELCNT ; INTO DELCNT RETURN ;********************************************************************** STROBE ;ROUTINE TO STROBE I/P TO 4094 AND SET LATCHES BSF PORTB,STRB_LINE ;SET STRB LINE NOP ;TIME DELAY (PROB NOT REQ'D) BCF PORTB,STRB_LINE ;CLEAR STRB LINE RETURN ;********************************************************************** INVERT ;ROUTINE TO INVERT BYTE TO BE SENT TO LCD(4094) TO TOGGLE BP ;THIS WORD WILL NOT BE DISPLAYED AS THE BP WILL BE INVERTED MOVLW 0xFF XORWF BYTEOUT,1 ;INVERT BYTE FOR BACKPLANE RETURN ;********************************************************************** >From: hung >Reply-To: hung >To: PICLIST@MITVMA.MIT.EDU >Subject: SPI code >Date: Tue, 4 May 1999 13:46:35 +1000 > >i'm working on a project that uses 74HC165 and 74HC595 to increase >the number of I/O pins of PIC12C672. The I/O pins will be connected to >a Keypad and a LCD screen. Does anyone know where i can find sample >code on that ? > >Thanks in advance ! ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com