Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LIST P=16F628A, R=DEC
- #include "P16F628A.INC"
- __config _INTRC_OSC_NOCLKOUT & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON
- CBLOCK 0x20
- d1
- d2
- eep_byte
- address
- read_back
- ENDC
- ORG 0x000
- movlw 7
- movwf CMCON ; CMCON=7 set comperators off
- ; initialize ports __ __
- movlw b'10010000' ; OE and WE high (disabled)
- movwf PORTA
- clrf address
- clrf eep_byte
- clrf PORTB
- bsf STATUS,RP0 ; bank 1
- bsf OPTION,7 ; disable PORTB pull ups
- clrf TRISA
- clrf TRISB
- bcf STATUS,RP0 ; bank 0
- loop call read_ee ; read byte from pic eeprom
- movwf eep_byte
- movf address,W ; give address to eprom
- movwf PORTA
- movf eep_byte,W ; give data to eprom
- movwf PORTB
- bcf PORTA,4 ; eeprom write enable
- call delay ; wait a little
- bsf PORTA,4 ; eeprom write disable
- call delay ; generous delays
- bsf STATUS,RP0 ; bank1
- movlw b'11111111'
- movwf TRISB ; set portB to inputs
- bcf STATUS,RP0 ; bank0
- bcf PORTA,7 ; eeprom output enable
- call delay
- movf PORTB,W
- movwf read_back ; read back data from eprom
- call delay
- bsf PORTA,7 ; eeprom output disable
- incf address,F ; increase address in eprom
- goto loop
- read_ee bsf STATUS,RP0 ; Read byte from eeprom
- movf address,W
- movwf EEADR
- bsf EECON1,RD
- movf EEDATA,W ; Store result in w
- bcf STATUS,RP0
- return
- delay movlw 0x1E
- movwf d1
- movlw 0x4F
- movwf d2
- delay_0 decfsz d1, f
- goto $+2
- decfsz d2, f
- goto delay_0
- goto $+1
- nop
- return
- org 2100h
- de "Hello"
- END
Add Comment
Please, Sign In to add comment