Hot!PICkit2 Devicefile Editor

Page: << < ..6 Showing page 6 of 6
Author
scasis
Super Member
  • Total Posts : 121
  • Reward points : 0
  • Joined: 2011/01/07 01:18:59
  • Location: 0
  • Status: offline
Re: PICkit2 Devicefile Editor 2017/07/08 08:31:24 (permalink)
3 (1)
HI,
Enhanced Midrange controllers use separate word (at 0x2005) for the 13 bit device revision and for the 13 bit device id. The Standard Midrange controllers store the two information in the save word (at 0x2006) with lower 5 bits using for revision. The script used by the Midrange/Standard family mask the 5 lower bit of device id off, making 0x3080 from value 0x3081 read form the controller.
 
To handle PIC16F1764-1769 Enhanced Midrange controllers a new family has to be defined with DeviceIdMask 0x3FFF, and a new ReadDevIDScript to read first the value form 0x8006 as DevideId than from 0x8005 as RevisionId.
post edited by scasis - 2017/07/08 08:40:17
mindthefrequency
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2017/02/27 18:15:29
  • Location: 0
  • Status: offline
Re: PICkit2 Devicefile Editor 2017/07/08 17:45:59 (permalink)
3 (1)
Thank you Scasis. Following your instructions:
  • I changed the Family field to 18 (Midrange/USB) in the PK2DeviceFile.dat file. This family already had a DeviceIdMask field value of 0x3FFF and that's why I selected it.
  • In the part list, I changed the DeviceId field of the PIC16F1765 back to 0x3081.
Now I get the PicKit 2 software to properly recognize the uc as a PIC16F1765.
Read, Verify, Erase and Blank Check operations are all successful.
 
Will post once I get some code up and running.
Thanks for you help.
 
 
mindthefrequency
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2017/02/27 18:15:29
  • Location: 0
  • Status: offline
Re: PICkit2 Devicefile Editor 2018/06/23 20:02:24 (permalink)
4 (1)
Did manage to program the PIC16F1765 using this hack.
 
Although the Pickit2 will recognize the correct Device ID of 0x3081 something is up as I'm getting the following message when I load my HEX file:
 no configuration words in hex file use file export to save
 
After manually setting up the configuration bits and writing a test firmware to the PIC I managed to make an LED start blinking at a fixed rate.
 
As suggested by Scasis, I went debugging the Device Id Read Script( scriptNumber=3 [MR_RdDevID1] ) only to realize it appears to be pointing to the correct memory address:
0    0xAAEE        tx LOAD CONFIGURATION COMMAND (0x00) -> sets the address to 0x8000
1    0xBB06                              
2    0xBB00                                
3    0xAAF2        delay 8 clock cycles (tx 8 clear bits)                                                
4    0xBB00                      
5    0xAAF2        delay 8 clock cycles (tx 8 clear bits)                                              
6    0xBB00                          
7    0xAAEE        tx INCREMENT ADDRESS COMMAND (0x06) -> sets address to 0x8001                
8    0xBB06       
9    0xBB06       
10   0xAAE9       LOOP -> repeats the INCREMENT ADDRESS COMMAND 5 times and sets the address to 0x8006
11   0xBB03         index offset to loop to = 3 (jumps to 7)
12   0xBB05         loop iterations = 5
13   0xAAEE        tx LOAD DATA FROM PROGRAM MEMORY COMMAND(4) -> puts 14bit data in the DATA line
14   0xBB06       
15   0xBB04        
16   0xAAF0        READ 14 bit data LSB and put it in the DATA line, advance the pointer
17   0xAAF0        READ 14 bit data MSB and put it in the DATA line, advance the pointer
(Total of 64 bits sent)
 
Not sure about How the Revision ID is being read, I did try to create a version of the above code where I repeat the process twice, but setting the latter address to 0x8005 instead of  0x8006.
This did not make any difference.
 
From here I went on debugging the script  scriptNumber=34 [MR_CfgRd2.1]  but this is also pointing to the right memory of 0x8007 and reading two words (14 bits long each) using the above method, but adding an extra loop in order to read one more word.
 
In my PkDeviceFile.dat, I have the following fields setup according to the PIC programming specs:
Family: 18 (Midrange/USB)
DeviceID: 0x3081
ProgramMem: 0x2000
ConfigWords: 2
ConfigAddr: 0x8007
ConfigMasks:
 [0] 0x3EFF
 [1] 0x3F87
ConfigBlank:
 [0] 0x3EFF
 [1] 0x3F87
ConfigRdPrepScript: 0
ConfigRdScript: 34 MR_CfgRd2.1
ConfigWrPrepScript: 0
ConfigWrScript: 35 MR_CfgWr2Int.1
ConfigMemEraseScript: 172 Mr_CfgRowErase.1
 
In my test firmware, my configuration bits are setup as follow:
; CONFIG1
; __config 0xC984
 __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
; CONFIG2
; __config 0xDCFB
 __CONFIG _CONFIG2, _WRT_OFF & _PPS1WAY_OFF & _ZCD_OFF & _PLLEN_OFF & _STVREN_OFF & _BORV_LO & _LPBOR_OFF & _LVP_OFF


 
 Any ideas on why the configuration bits ARE NOT being found/loaded by the PicKit2 software?
 I mean, could this be due to the lack of the process of reading the Revision ID, or something I'm missing in the PkDeviceFile or ASM?
 
Any help is greatly appreciated.
Kind regards.
scasis
Super Member
  • Total Posts : 121
  • Reward points : 0
  • Joined: 2011/01/07 01:18:59
  • Location: 0
  • Status: offline
Re: PICkit2 Devicefile Editor 2018/06/25 01:13:18 (permalink)
0
Hi mindthefrequency,
since midrange instructions and configuration words have 14 bits they can be stored only in two bytes in hex files the configuration address should be doubled (0x1000E). The Device Id and Revision Id could be read by entering configuration, advance pointer 6 times, read a word (Device Id), reenter configuration, advance pointer 5 times, read a word (Revision Id).
mindthefrequency
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2017/02/27 18:15:29
  • Location: 0
  • Status: offline
Re: PICkit2 Devicefile Editor 2018/06/25 07:33:11 (permalink)
0
My man,
Thank you so much for your help with this, It is obvious you're a Pic super hero!
I'll leave the steps and code here for others to follow if they're stuck like I have been (for a year I just noticed).
 
In order to program a PIC16F1765 using the PicKit2 hardware/software:
  1. create a backup copy of your PkDeviceFile.dat (located in the PicKit2 software folder) and store it somewhere safe.
  2. Before start editing the PkDeviceFile.dat make sure you grand the file with all permissions required, otherwise you'll be unable to save the file after editing (this happened to me when I tried editing a copy of PkDeviceFile.dat downloaded from one of this forum's links, using Win7).
  3. use the PICKit2 Device File Editor software to open and edit the PkDeviceFile.dat file in the PicKit2 folder.
  4. In the Device Families left menu branch:
    1. duplicate the family Midrange/1.8V Min.
    2. save the file, and reopen the same file again(according to other posts, this has to be done in order to avoid a software bug).
  5. select the Device Family you've just created:
    1. update it's family ID to the next number of the last existing family's familyID.
    2. Rename the family to Midrange/Enhanced.
    3. Again, save the file and re-open it.
  6. In the Parts List branch in the left menu:
    1. select and duplicate an existing entry.
    2. Save the file and re-open it.
  7. In the Parts List menu branch, select the new part you just created , and edit every field according to your PIC's programming specs sheet. In the following example I've ommited some fields for simplicity:
    • PartName: PIC16F1765
    • Family: Set to the number of the FamilyId you've created in step 5
    • DeviceId: 0x3081
    • ProgramMem: 0x2000
    • ConfigWords: 2
    • ConfigAddr: 0x1000E
    • UserIDwords: 4
    • UserIDAddr: 0x8000
    • ConfigMaks:
      • 0x3EFF
      • 0x3F87
    • ConfigBlank
      • 0x3EFF
      • 0x3F87
    • CPConfig: 1
    • VddMin: 2.5
    • VddMax: 5
    • VddErase: 2.5
    • CalibrationWords: 10
    • ChipEraseScript: 4
    • ProgMemAddrSetScript: 230
    • ProgMemAddrBytes: 0
    • ProgMemRdScript: 5
    • ProgMemRdWords: 0x20
    • UserIdRdScript: 7
    • ConfigRdScript: 34
    • progMemWrScript: 281
    • ProgMemWrWords: 0x20
    • UserIdWrScript: 33
    • ConfigWrScript: 35
    • OSCCALWrScript: 260
    • ProgMemEraseScript: 110
    • ConfigmemEraseScript: 172
    • TestMemoryRdScript: 132
    • TextMemoryRdWords: 0x08
  8. Save the file and re-open it.
  9. From the Scripts branch in the left menu:
    1. select and duplicate the script MR_UserIDRd4.1 (ScriptNumber: 7)
    2. Save the file and re-open it.
  10. Select the script you just created:
    1. update the field ScriptNumber to the number following the last script's ScriptNumber field (This is usually the last script at the bottom of the Script list).
    2. update the ScriptName to EN_UsrIDRd4.1 or to something else that makes sense to you
    3. update the Script array field to the following:
      • 0    0xAAEE        tx LOAD CONFIGURATION COMMAND (0x00) -> sets the address to 0x8000
        1    0xBB06         N bits = 6                            
        2    0xBB00         literal = 0                         
        3    0xAAF2        WRITE_BYTE_LITERAL         delay 8 clock cycles (tx 8 clear bits)
        4    0xBB00         Byte to be sent = 0                
        5    0xAAF2        WRITE_BYTE_LITERAL         delay 8 clock cycles (tx 8 clear bits)
        6    0xBB00        Byte to be sent = 0                    
        7    0xAAEE        tx INCREMENT ADDRESS COMMAND (0x06) -> sets address to 0x8001
        8    0xBB06         N bits = 6
        9    0xBB06         literal = 6
        10   0xAAE9        LOOP -> repeats the INC ADDR COMMAND 5 times, sets the address to 0x8006
        11   0xBB03         index offset to loop to = 3 (jumps to 7)
        12   0xBB05         loop iterations = 5
        13   0xAAEE         tx LOAD DATA FROM PROGRAM MEMORY COMMAND -> tx 14bit data
        14   0xBB06         N bits = 6
        15   0xBB04         literal = 4
        16   0xAAF0        READ 14 bit data LSB and put it in the DATA line, advance the pointer
        17   0xAAF0        READ 14 bit data LSB and put it in the DATA line, advance the pointer
        18   0xAAEE        tx LOAD CONFIGURATION COMMAND (0x00) -> sets the address to 0x8000
        19   0xBB06         N bits = 6                            
        20   0xBB00         literal = 0                         
        21   0xAAF2        WRITE_BYTE_LITERAL         delay 8 clock cycles (tx 8 clear bits)
        22   0xBB00         Byte to be sent = 0    
        23   0xAAF2        WRITE_BYTE_LITERAL         delay 8 clock cycles (tx 8 clear bits)
        24   0xBB00        Byte to be sent = 0    
        25   0xAAEE        tx INCREMENT ADDRESS COMMAND (0x06) -> sets address to 0x8001
        26   0xBB06         N bits = 6
        27   0xBB06         literal = 6
        28   0xAAE9        LOOP -> repeats the INC ADDR COMMAND 6 times, sets the address to 0x8007
        29   0xBB03         index offset to loop to = 3 (jumps to 25)
        30   0xBB06         loop iterations = 6
        31   0xAAEE        tx LOAD DATA FROM PROGRAM MEMORY COMMAND -> tx 14bit data
        32   0xBB06         N bits = 6
        33   0xBB04         literal = 4
        34   0xAAF0        READ 14 bit data LSB and put it in the DATA line, advance the pointer
        35   0xAAF0        READ 14 bit data LSB and put it in the DATA line, advance the pointer

    4. Once again, save the file and re-open it.
  11. From the Device Families branch in the left menu:
    1. select the family you created in step 5 (Midrange/enhanced)
    2. set the field ReadDevIDScript to the number of the script you've created in steps 9-10.
    3. save the file.
  12. You should be good to go.
 
Corrections and suggestions are more then welcome!
 
Usefull resources to learn about this stuff:
Thanks for all who contributed to this knowledge base in previous posts.
 
 
 
 
scasis
Super Member
  • Total Posts : 121
  • Reward points : 0
  • Joined: 2011/01/07 01:18:59
  • Location: 0
  • Status: offline
Re: PICkit2 Devicefile Editor 2018/06/25 08:14:27 (permalink)
0
Hi
the UserIDAddr should be doubled as well, 0x10000 instead of 0x8000.
davegsm82
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2007/02/05 15:48:34
  • Location: 0
  • Status: offline
Re: PICkit2 Devicefile Editor 2018/07/11 12:50:59 (permalink)
0
MindTheFrequency, 

Do you think that the 18F22k40 with it's SPI programming method could be programmed in the same way as the 16F1765? I can't seem to find the programming method for that device, or at least not one that is explained in the same way as the 18F26K40?
 
Cheers, Dave.
mindthefrequency
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2017/02/27 18:15:29
  • Location: 0
  • Status: offline
Re: PICkit2 Devicefile Editor 2018/07/11 15:19:22 (permalink)
0
Hi Dave GSM,
 
I got my programming specs from here.
There should be a simmilar document for the 18F22k40 describing all programming details. You should look for it in the microchip website.
 
This guys are up to something in regards to using PicKit2 hardware.
 
 good luck
 
 
 
 
scasis
Super Member
  • Total Posts : 121
  • Reward points : 0
  • Joined: 2011/01/07 01:18:59
  • Location: 0
  • Status: offline
Re: PICkit2 Devicefile Editor 2018/07/11 23:30:38 (permalink)
4 (1)
Hi,
in one word yes. It is possible to program nearly all pic micro device form 16C5x to PIC32MZ. Only the firmware and the control program has to be changed.
PK2-96: PIC18F66K80 datasheet family, PIC18F87K90 datasheet family, PIC18F87K22 datasheet family:
  With a revised pair of ChipErasePrepScript and ChipEraseScript all area can be erased.
PIC32: PICkit2 has not enough memory:
  But the part itself has.
davegsm82
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2007/02/05 15:48:34
  • Location: 0
  • Status: offline
Re: PICkit2 Devicefile Editor 2018/07/12 03:41:16 (permalink)
0
Thanks, mindthefrequency and scasis.

Scasis, I know it's asking a lot but could you walk me through the necessary changes to the PK2 file to be able to program the 18F22K40 (and associated families)? You mention that the firmware needs to be modified, do you have any details on this, or could you point me to where I can find it.

I did make some changes myself a while ago to the PK2 file but never actually got it to recognise the device ID of the PIC. can't remember all the details now unfortunately but seem to remember that the timings were a problem, i.e. the PIC seemed to want 16 bits clocked in all at once, rather than 8 bits, a very short pause, then another 8 bits that the PK2/PK3 gives. It looked like the PIC 'Dat' line was going in to a high-impedance state momentarily between the 2 bytes.

Thank you, I appreciate your help.
 
Dave.
scasis
Super Member
  • Total Posts : 121
  • Reward points : 0
  • Joined: 2011/01/07 01:18:59
  • Location: 0
  • Status: offline
Re: PICkit2 Devicefile Editor 2018/07/13 09:15:00 (permalink)
4 (1)
Hi
The problems of 18F families with SPI programming method on PICkit2:
The PICkit2 application uses 2 bytes for an instruction code of 18F, and places 2 bytes to download buffer. It has a possibility to shift the code and data up with several bits. It would be useful to make the trailing 0 bit, but it would make 3 bytes form an instruction.
PICkit2 firmware uses two lines for data in SPI communication bit 18F uses only one. In the firmware there is no possibility to send only one bit on SPI, to use the same data line for data to be shifted in and out and to make simple arithmetic and logic functions (temporary store data, shift data, bit reverse data, change byte order).  
Page: << < ..6 Showing page 6 of 6
Jump to:
© 2018 APG vNext Commercial Version 4.5