EEPROM write with USB


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Jun 2011
    Posts
    19

    Default Re: EEPROM write with USB

    I can send and receive data to the mcu. I'm using the usbout command for debugging right now. It sends 3 16 bi twords in one buffer to hyperterminal right now. I just can't figure out how to send a specific value to the mcu and have it wait for 256 byte of data and rewrite the contents of the eeprom with those values. I would also lite to dump the contents of the mcu eeprom back to my pc.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: EEPROM write with USB

    To start with, the DATA and EEPROM commands only work at compile time. Use READ and WRITE during run time.

    Concept to receive data via USB then WRITE to eeprom.

    Send a small array to the MCU then check the array for a specific value.
    If the value is X the jump to a WHILE or DO loop.
    Wait for data to be recieved that you want to WRITE to the eeprom.
    Use a FOR/NEXT loop to loop through the array received via USB, (this will be a different array/buffer than before)
    WRITING each byte of the array to the next address of the eeprom.
    When finished change the variable X to another value that do not mean GOTO the DO loop.
    RETURN to main program.

    These may help
    http://www.picbasic.co.uk/forum/show...rray+to+eeprom
    http://www.picbasic.co.uk/forum/show...rray+to+eeprom
    http://www.picbasic.co.uk/forum/showthread.php?t=544

    I am not in a place to write code at the moment but you may get the idea.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jun 2011
    Posts
    19

    Default Re: EEPROM write with USB

    I think this is what you intended for me to do.. I'm not sure how to advance the array location in the loop. You will see my comment in the code. Thank you again for the help!
    Code:
     usbservice
    doloop:
           inbyte = 1
           USBin 3, action, inbyte, doloop2        ' Get a char from usb port
    verify:
           IF action = 102 THEN   ' Verify connection
           USBout 3, action, 1, verify
           ENDIF    ' end of verify action
         '  IF action = 117 THEN  ' Write EEPROM
         '  USBOUT 3, action, 1, doloop2
         '  tempval = 0
    tlabel2:
         '  USBin 3, char, inbyte, tlabel2
         '  WRITE tempval, char
         '  USBout 3, char, 1, startloop
          ' tempval = tempval + 1
          ' IF tempval < 255 THEN tlabel2
         '  ENDIF ' end of Write action
    valuesout:
           IF action = 99 THEN    ' Return last input and output
           USBout 3, mafout, 6, valuesout
           ENDIF ' end of IO action
           IF action = 107 THEN   ' Dump EEPROM
           tempval = 0
    Dumploop:
           Read tempval, epromdump[0]  'epromdump is a 256 byte array
            tempval = tempval + 1 'advance to the next eeprom location 
            'not sure how to advance places in the array for the new eeprom value
            USBout 3, epromdump, 256, dumploop

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default Re: EEPROM write with USB

    'not sure how to advance places in the array for the new eeprom value
    Check at the front of the PBP manual on arrays. You use a FOR loop to scan through the array, using a variable as position pointer.

    Have you considered using Darrel's USB interrupt routine?
    http://darreltaylor.com/DT_INTS-18/home.html

    Robert

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: EEPROM write with USB

    Code:
    DATA @1,$31,$32,$33,$34,$35,$36,$37,$38,$39,$30
       X = 0
       PAUSE 5000 : Pause 5000   'TIME TO START TERMINAL
    idleloopq:
    FOR X = 1 TO 10
        READ X,BUFFER
        USBOut 3, buffer, 1, idleloopq
    	PAUSE 250
    	NEXT
    	END
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default Re: EEPROM write with USB

    Just make sure you don't have a big pause after USB started, probably going to lose connection.

    Robert

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: EEPROM write with USB

    Quote Originally Posted by Demon View Post
    Just make sure you don't have a big pause after USB started, probably going to lose connection.

    Robert
    I should have mentioned that my USBSERVICE is interrupt driven so PAUSE does not matter.
    Dave
    Always wear safety glasses while programming.

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