• AVR Freaks

Autoprogramming for PK2

Author
hycom
Senior Member
  • Total Posts : 170
  • Reward points : 0
  • Joined: 2006/11/15 06:26:46
  • Location: germany, near cologne
  • Status: offline
2008/03/04 10:56:37 (permalink)
0

Autoprogramming for PK2

Hello,
I wrote a little batch file for the PicKit2 to enable autoprogramming for those who a ZIF-socket, like me with the 12F629. No button press is neccesary.
The insertion and removal of the Pic is detected. (~3 Hz)
Path, Pic-model and hex-file are hardcoded.
Verify is done 1. with the voltage from the device file (here 5V)
and 2. with the lowest possible voltage (here 2.5V)
If you uncomment the three lines after ':bcheck' you get the chance to change the laready programmed Pic. (Since a succesful blank check took more time than an erase, I don't use it.)
Every error will stop the batch with a massage. Quit with ctrl/c.
 
Before I did it, I was concerned of:
1. If the moment of closing the ZIF is problematic. I programmed more than one hundret today, at all phases (well, as good as I'am able to...) without a single error.
2. If it's OK for the already programmed Pic to be brought to programming mode constantly (If not taken out directly) . So I left 2 Pics, 4 hours each, in the 'wait for take out-mode'. No verify errors, no lost oscal value, everything fine.
Perhaps it is helpfull for others too.  Comments?



Regards



      @echo off
                                                            :: 4. march 2008, Roger
      cd c:\pk2
                                                            :: To calm down ;)
      color 2a
                                                            :: Just to reset
      pk2cmd.exe -h1
:start
      cls
      echo Put in PIC 12F629
:loop
                                                            :: Read device ID, to file
      pk2cmd exe -ppic12f629 -i >out.txt
      if errorlevel 1 goto error
                                                            :: Found 12F629? Output into Nirvana
      find /c "0F90" out.txt >nul
                                                            :: If not, loop
      if errorlevel 1 goto loop        
:bcheck
                                                            :: Blank Check, to file
::      pk2cmd.exe -ppic12f629 -c >out.txt
      if errorlevel 1 goto error
                                                            :: PIC erased? Output into Nirvana
::    find /c "NOT" out.txt >nul
::    if errorlevel 1 goto prg
                                                            :: If not, warning
::    goto nerased
:erase
      echo Erase PIC
                                                            :: Erase Device
      pk2cmd.exe -ppic12f629 -e >nul
      if errorlevel 1 goto error
:prg
      echo Write rogramm and eeprom
                                                            :: Program program and eeprom
      pk2cmd.exe -ppic12f629 -fTest.hex -mpe >nul
      if errorlevel 1 goto error
           
      echo Verify at 5.0V
                                                            :: Verify program and eeprom
      pk2cmd.exe -ppic12f629 -fTest.hex -ype >nul
      if errorlevel 1 goto error 
      echo Verify at 2.5V
                                                            :: VDD to 2,5V. Verify program and eeprom
      pk2cmd.exe -ppic12f629 -fTest.hex -a2.5 -ype >nul
      if errorlevel 1 goto error
      echo Write configuration
                                                            :: Program config and verify
      pk2cmd.exe -ppic12f629 -fTest.hex -mc -yc >nul
            if errorlevel 1 goto error
      echo PIC programmed without errors
      echo.
      echo Take out PIC
:tout
                                                            :: Read device ID, to file
      pk2cmd exe -ppic12f629 -i >out.txt
      if errorlevel 1 goto error
                                                            :: PIC taken out? Output into Nirvana
      find /c "0000" out.txt >nul
                                                            :: If still in, loop
      if errorlevel 1 goto tout
      goto start
      goto end
:nerased
      echo PIC already programmed!
      echo Change PIC and press a button
      pause >nul
      goto start
:error
      cls
      echo An error occurred!!!
      echo Error code : %errorlevel%
      echo.
      echo Press a button to quit.
      pause >nul
:end
 

p-brane resident
#1

2 Replies Related Threads

    PICkit2Dev
    Super Member
    • Total Posts : 994
    • Reward points : 0
    • Joined: 2006/09/27 08:41:47
    • Location: 0
    • Status: offline
    RE: Autoprogramming for PK2 2008/03/04 11:57:53 (permalink)
    0
    Thanks for sharing this - it could be a great utility for some users.
     
    I don't think there should be a problem caused by repeatedly reading the Device ID while waiting for take-out.
    #2
    hycom
    Senior Member
    • Total Posts : 170
    • Reward points : 0
    • Joined: 2006/11/15 06:26:46
    • Location: germany, near cologne
    • Status: offline
    RE: Autoprogramming for PK2 2008/03/06 16:34:11 (permalink)
    0
    I don't think there should be a problem caused by repeatedly reading the Device ID while waiting for take-out.

    Seems right, made more tests, still no problem, the top of the batch is better this way.
        @echo off
                            :: 5. March 2008, Roger
        cd c:\etronic\
                            :: To calm down ;)
        color 2a
        cls
        echo PicKit 2
                            :: Display versions
        pk2cmd.exe -ppic12f629 -?v
        if errorlevel 1 goto error
                            ::Wait 4 sec.
        pk2cmd.exe -p%PIC% -h4 >nul
        if errorlevel 1 goto error
    :start

    Perhaps, when everything else is done, you can add it to the GUI, specially the low voltage verify. Smile

    Regards

    p-brane resident
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5