24Cxx copier with PIC 16F84A


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: 24Cxx copier with PIC 16F84A

    Did one eleven yrs back
    Might have been my first PBP program.



    I left this note in the project folder:
    This hex expects normaly closed switches for Copy and Verify.
    The LEDs need their polaritys reversed and are to be tied to +5volts
    instead of ground for this hex also.
    Code:
    ' 24LC16B SERIAL EEPROM DUPLICATOR / ERASER
    ' (c) Brek Martin 2002!
    '
    pause 100                                     'breif pause at startup
    INCLUDE "modedefs.bas"                        'include serial modes
    B0 var byte                                   'set up variables
    B1 var byte                                   'B0, B1 & B2 as bytes
    B2 var byte
    addr var byte                                 'set up address & chip
    chip var byte                                 'variables for EEPROM
    B0 = 0                                        'clear copy buffer
    B1 = 0                                        'clear verify buffer
    trisb.0 = 1                                   'set button pins as inputs
    trisb.3 = 1
    '
    '
    fird:
    '
    onel:
    IF portb.3 = 1 THEN twol                      'checking for first of two buttons
    '                                              at startup
    '
    GOSUB pron
    GOSUB pron
    GOSUB pron
    GOSUB pron
    GOSUB pron
    GOSUB pron
    GOSUB pron
    GOSUB pron
    GOSUB pron
    GOSUB pron
    GOSUB pron
    '
    '
    '
    '
    '
    '
    comd:
    IF portb.3 = 1 THEN dupl
    IF portb.0 = 1 THEN eras
    goto comd
    '
    dupl:
    chip = 158                                    'set chip variable to the
    '                                              value of first location minus 2
    rone:
    chip = chip + 2                               'add 2 to the chip variable
    IF chip = 176 THEN rnin                       'check for last chip location
    addr = 0
    aone:                                         'go back here every 256 bytes
    high portb.1                                  'turn source LED on
    low portb.1                                   'and off again
    portb.1 = 0
    I2CREAD porta.0,porta.1,chip,addr,[B0],eror   'read the byte from source EEPROM
    'serout2 portb.7,16780,[hex B0," "]            'send byte out serial port
    I2CWRITE portb.4,portb.5,chip,addr,[B0],eror  'write the byte to target EEPROM
    pause 15                                      'wait for the write to complete
    high portb.2                                  'turn target LED on
    low portb.2                                   'and off again
    I2CREAD portb.4,portb.5,chip,addr,[B1],eror   'read byte back from target EEPROM
    IF B0 != B1 THEN verr                         'verify the copied byte
    IF addr = 255 THEN rone                       'check for last address of each location
    addr = addr + 1                               'add 1 to addr variable for next read
    goto aone                                     'go back for next read
    rnin:
    serout portb.7,n2400,[" Copy completed!"]
    GOSUB cpyc
    GOSUB cpyc
    GOSUB cpyc
    GOSUB cpyc
    GOSUB cpyc
    GOSUB cpyc
    goto fnsh
    '
    '
    eror:                                         'label to jump to if error is detected
    serout portb.7,n2400,[" A read/write error occured !"]
    GOSUB eled
    GOSUB eled
    GOSUB eled
    GOSUB eled
    goto fnsh
    verr:
    serout portb.7,n2400,[" A verify error occured !"]
    GOSUB eled
    GOSUB eled
    GOSUB eled
    GOSUB eled
    GOSUB eled
    goto fnsh
    '
    eras:
    chip = 158                                    'set chip variable to the
    B0 = 0                                        'value of first location minus 2
    B1 = 0                                        'reset copy and verify buffers
    rtwo:
    chip = chip + 2                               'add 2 to the chip variable
    IF chip = 176 THEN rten                       'check for last chip location
    addr = 0
    atwo:                                         'go back here every 256 bytes
    low portb.2                                   'turn LED on
    I2CWRITE portb.4,portb.5,chip,addr,[B0],eror  'write B0 to EEPROM (B0 = 0)
    pause 15                                      'wait for write to complete
    I2CREAD portb.4,portb.5,chip,addr,[B1],eror   'read the byte back in
    IF B0 != B1 THEN verr                         'verify the byte has zero value
    'serout2 portb.7,16780,[hex B0," "]            'send byte out serial port
    high portb.2                                  'turn LED off
    IF addr = 255 THEN rtwo                       'check for last address of each location
    addr = addr + 1                               'add 1 to addr variable for next read
    goto atwo                                     'go back for next read
    rten:
    serout portb.7,n2400,[" Erase completed!"]
    GOSUB cpyc
    GOSUB cpyc
    GOSUB cpyc
    GOSUB cpyc
    GOSUB cpyc
    GOSUB cpyc
    '
    fnsh:
    goto comd                                     'go back and check for button push
    '
    '
    '                                  >>>>>>>>>>>>and now all the gosub LED sequences
    pron:                                        
    low portb.1                                   'display power on LED sequence
    pause 75
    low portb.2
    pause 75
    high portb.1
    pause 75
    high portb.2
    pause 75
    return
    '
    cpyc:                                         'start copy completed LED sequence
    low portb.1
    pause 250
    low portb.2
    pause 250
    high portb.1
    pause 250
    high portb.2
    pause 250
    return
    '
    eled:                                         'start error LED sequence
    low portb.1
    low portb.2
    pause 1000
    HIGH portb.1
    HIGH portb.2         
    pause 1000
    return
    '
    twol:
    IF portb.0 = 1 THEN thrl                      'checking for second of two buttons
    goto comd                                     'at startup
    '
    thrl:                                         'custom sequence starts here
    low portb.1                                   'start LED sequence for early command
    '
    '
    I2CWRITE portb.4,portb.5,164,62,["T"],eror    'EDIT SOME CUSTOM CODE HERE
    pause 20
    I2CWRITE portb.4,portb.5,164,61,["U"],eror
    pause 20
    I2CWRITE portb.4,portb.5,164,60,["R"],eror
    pause 20
    '
    '
    I2CWRITE portb.4,portb.5,164,150,["T"],eror   'AND HERE
    pause 20
    I2CWRITE portb.4,portb.5,164,149,["U"],eror
    pause 20
    I2CWRITE portb.4,portb.5,164,148,["R"],eror
    pause 20
    '
    '
    gosub cpyc                                     'goto the LED sequence
    gosub cpyc
    '
    end
    Last edited by Art; - 28th October 2013 at 10:11.

Similar Threads

  1. PIC 16F84A and 7segment LED dispay
    By select in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st November 2007, 22:01
  2. Slot Car timer with pic 16f84a
    By Snap in forum Serial
    Replies: 4
    Last Post: - 5th July 2007, 05:58
  3. ICSP using a 16F84a to program 24CXX
    By aftab in forum mel PIC BASIC
    Replies: 26
    Last Post: - 8th April 2007, 12:39
  4. send and receive data using pic 16f84a
    By PoTeToJB in forum Serial
    Replies: 1
    Last Post: - 25th February 2006, 15:47
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th March 2005, 00:14

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts