This is a multi-part message in MIME format. ------=_NextPart_000_00EC_01C295F2.718103E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi All, I am attaching a program that hopefully will read a EEPROM but it does not work. I tried to modify a program from Dave Benson of Square One. Any help or advice will be most appreciated. Thanks, Royce ------=_NextPart_000_00EC_01C295F2.718103E0 Content-Type: application/octet-stream; name="Eepread.asm" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="Eepread.asm" ; Serial EPROM test C56F288.ASM ; 93C56 EPROM routines X 8 organization ORG =3D 0 ; Inspired by a 93C46 program by Dave Benson LIST P=3D16f628, n =3D 55, st =3D OFF INCLUDE P16F628.INC ; XT oscillator configuration __CONFIG _XT_OSC & _WDT_OFF & _PWRTE_OFF & _LVP_OFF ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ; Instruction set ; Inst Stop Op Address Data Data ; Bit Code In Out ; READ 1 10 x A7 A6 A5 A4 A3 A2 A1 A0 -- D7 - D0 ; EWEN 1 00 1 1 X X X X X X X -- High-Z ; ERASE 1 11 x A7 A6 A5 A4 A3 A2 A1 A0 -- *RDY/BSY ; ERAL 1 00 1 0 X X X X X X X -- *RDY/BSY ; WRITE 1 01 x A7 A6 A5 A4 A3 A2 A1 A0 D7 - D0 *RDY/BSY ; WRAL 1 00 0 1 X X X X X X X D7 - D0 *RDY/BSY ; EWDS 1 00 0 0 X X X X X X X -- High-Z ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ; Circuit diagram ; PIC BOARD 93C56 ; RA3 (2) ----- CS (1) VCC (8) +5 V ; RA2 (1) ----- CLK (2) DC (7) NC ; RA1 (18) ----- DI (3) ORG (6) GND ; RA0 (17) ----- DO (4) GND (5) GND ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D radix hex ; Bit Equates CS equ 0x03 ; RA0,3 CLK equ 0x02 ; RA0,2 DI equ 0x00 ; RA0,0 DO equ 0x01 ; RA0,1 ; Equates address equ 0x20 work equ 0x21 count equ 0x22 databyte equ 0x23 temp equ 0x24 d1 equ 0x25 d2 equ 0x26 d3 equ 0x27 d1val equ 0x28 ; org 0x000 ; Reset vector is at 0x000 ; start bsf STATUS,RP0 ; switch to bank 1 movlw b'00000001' ; bit 0 =3D input movwf TRISA movlw b'00000000' ; outputs movwf TRISB bcf STATUS,RP0 ; switch back to bank 0 bcf PORTA,1 ; initialize bcf PORTA,2 ; initialize bcf PORTA,3 ; initialize movlw 0x00 ; 00000000 movwf PORTB ; LEDs off init movlw 0x00 ; define test address movwf address showloop call read ; read subroutine movf work,w ; get byte movwf PORTB ; display via LEDs ; insert delay here to observe data better incfsz address,F goto showloop endloop goto endloop ; done ewensub movlw b'10010000' ; start, opcode and A8 bits movwf work ; to work call send4bits ; send ewen op code movlw b'1000000' ; rest of command movwf work ; to work call send8bits ; send ewen op code return ewdssub movlw b'10000000' ; start, opcode and A8 bits movwf work ; to work call send4bits ; send ewds op code movlw b'00000000' ; rest of command call send8bits ; send ewds op code return write bsf PORTA,3 ; cs high call ewensub ; erase/write enable bcf PORTA,3 ; cs low nop ; 1 microsecond min bsf PORTA,3 ; cs high movlw b'10100000' ; start bit, opcode, first addr bit movwf work ; store in work call send4bits ; send first 4 bits movf address,w ; get address movwf work ; store in work call send8bits ; send address movf databyte,w ; get data movwf work call send8bits ; send data bcf PORTA,3 ; cs low nop ; 1 microsecond min bsf PORTA,3 ; cs high ecycle2 btfss PORTA,0 ; erase cycle complete? goto ecycle2 ; not yet bcf PORTA,3 ; cs low nop ; 1 microsecond min call ewdssub ; yes, erase/write disable bcf PORTA,3 ; cs low nop ; 1 microsecond min return read bsf PORTA,3 ; cs high movlw b'11000000' ; start bit, opcode, first addr bit movwf work ; store in work call send4bits ; send first 4 bits movf address,w ; get address movwf work ; store in work call send8bits ; send address call getprom ; shift hi 8 bits out of eeprom movf work,w bcf PORTA,3 ; cs low nop ; 1microsecond min return ; exit sub send4bits movlw 0x04 ; count =3D 4 movwf count goto sbit ; send start, opcode, first addr bits send8bits movlw 0x08 ; count =3D 8 movwf count sbit call sendbit ; send 1 bit decfsz count,f ; done? goto sftwork ; no return ; yes sftwork rlf work,f ; shift work left goto sbit ; again sendbit bcf PORTA,1 ; default btfsc work,7 ; test work bit 7 bsf PORTA,1 ; bit is set shift1 bsf PORTA,2 ; shift bcf PORTA,2 return getprom movlw 0x08 ; count=3D8 movwf count shift2 bsf PORTA,2 ; shift bcf PORTA,2 movf PORTA,W ; read port A movwf temp ; store copy rrf temp,f ; rotate bit into carry flag rlf work,f ; rotate carry flag into work decfsz count,f ; decrement counter goto shift2 return ; done erase bsf PORTA,3 ; cs high call ewensub ; erase/write enable bcf PORTA,3 ; cs low nop ; 1 microsecond min bsf PORTA,3 ; cs high movlw b'11100000' ; start, opcode and A8 bits movwf work ; store in work call send4bits ; send command movf address,W ; load address movwf work ; move to work reg call send8bits ; remainder of command bcf PORTA,3 ; cs low nop ; 1 microsecond min bsf PORTA,3 ; cs high ecycle1 btfss PORTA,0 ; erase cycle complete? goto ecycle1 ; not yet bcf PORTA,3 ; cs low nop ; 1microsecond min call ewdssub ; yes, erase/write disable bcf PORTA,3 ; cs low nop ; 1microsecond min return end =1A ------=_NextPart_000_00EC_01C295F2.718103E0-- -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu