Guest User

Untitled

a guest
Jul 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. LIST P=16F628A, R=DEC
  2.  
  3. #include "P16F628A.INC"
  4.  
  5. __config _INTRC_OSC_NOCLKOUT & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON
  6.  
  7. CBLOCK 0x20
  8. d1
  9. d2
  10. eep_byte
  11. address
  12. read_back
  13. ENDC
  14.  
  15. ORG 0x000
  16.  
  17. movlw 7
  18. movwf CMCON ; CMCON=7 set comperators off
  19.  
  20. ; initialize ports __ __
  21. movlw b'10010000' ; OE and WE high (disabled)
  22. movwf PORTA
  23.  
  24. clrf address
  25. clrf eep_byte
  26. clrf PORTB
  27.  
  28. bsf STATUS,RP0 ; bank 1
  29. bsf OPTION,7 ; disable PORTB pull ups
  30. clrf TRISA
  31. clrf TRISB
  32. bcf STATUS,RP0 ; bank 0
  33.  
  34. loop call read_ee ; read byte from pic eeprom
  35. movwf eep_byte
  36. movf address,W ; give address to eprom
  37. movwf PORTA
  38. movf eep_byte,W ; give data to eprom
  39. movwf PORTB
  40. bcf PORTA,4 ; eeprom write enable
  41. call delay ; wait a little
  42. bsf PORTA,4 ; eeprom write disable
  43. call delay ; generous delays
  44.  
  45. bsf STATUS,RP0 ; bank1
  46. movlw b'11111111'
  47. movwf TRISB ; set portB to inputs
  48. bcf STATUS,RP0 ; bank0
  49.  
  50. bcf PORTA,7 ; eeprom output enable
  51. call delay
  52. movf PORTB,W
  53. movwf read_back ; read back data from eprom
  54. call delay
  55. bsf PORTA,7 ; eeprom output disable
  56.  
  57. incf address,F ; increase address in eprom
  58.  
  59. goto loop
  60.  
  61. read_ee bsf STATUS,RP0 ; Read byte from eeprom
  62. movf address,W
  63. movwf EEADR
  64. bsf EECON1,RD
  65. movf EEDATA,W ; Store result in w
  66. bcf STATUS,RP0
  67. return
  68.  
  69. delay movlw 0x1E
  70. movwf d1
  71. movlw 0x4F
  72. movwf d2
  73. delay_0 decfsz d1, f
  74. goto $+2
  75. decfsz d2, f
  76. goto delay_0
  77. goto $+1
  78. nop
  79. return
  80.  
  81. org 2100h
  82. de "Hello"
  83.  
  84. END
Add Comment
Please, Sign In to add comment