PIC EEPROM programmer - almost working, not quite

Discussion in 'Embedded Systems and Microcontrollers' started by Tekk, Dec 19, 2009.

  1. Tekk

    Thread Starter Member

    Apr 18, 2009
    16
    0
    I've been working on a homemade Z80 computer, and it's time to load some sort of program into it to see if it's working.

    Since I don't have an EEPROM programmer, I decided to make a simple PIC program to load a program onto the EEPROM I'm going to be using with the Z80.

    I don't think it's working.
    If I hook up leds to the address output, I can see the address incrementing. I can also see the write enable going low and high for each byte as I should. But when I hook up leds to the data output, they are always off.

    Here's my source code, can you guys spot anything wrong with it?
    Also, I suspect it might be a hardware fail (do I need pull up/down resistors of any kind when connecting the PIC to the EEPROM?)

    Sorry if the indentation looks weird, Notepad adjusts tab widths to make it look nice but I don't think it's going to do that here.

    Thanks a lot.

    Code ( (Unknown Language)):
    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
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    You set port b to all inputs in the middle of the loop but never change it back.
     
  3. Tekk

    Thread Starter Member

    Apr 18, 2009
    16
    0
    That seems like the problem, I'll fix that.

    Thanks!
     
  4. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    I'd like to build a PIC based eprom programmer one of these days, I've got a lot of old window eproms.

    Can you please post your schematic?
     
Loading...