• AVR Freaks

Helpful ReplyHot!PICkit 2 loses Bandgap setting of 16F630 when programming

Author
holzwurm
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2010/01/23 16:03:30
  • Location: 0
  • Status: offline
2010/01/23 16:23:00 (permalink)
0

PICkit 2 loses Bandgap setting of 16F630 when programming

Hello,

Scenario:
In PICkit 2, I do the steps
- File -> Import Hex
- Button: Write
Then PC2 seemingly performs all necessary steps, and also displays the OSCCAL and the Bandgap value.
However, on the PIC (a 16F630) the bandgap value is always set to 00.
This can be seen by re-reading the just programmed PIC by pressing the button "Read". Now the PC2 displays Bandgap value 0.

This behaviour can also be reproduced by "read"ing a new, unused PIC (choose one with a Bandgap other than 0), and then "write"ing what just has been read, then "read" again, now showing a bandgap of 0.

This behaviour can also be reproduced by "erase"ing a new, unused PIC (choose one with a Bandgap other than 0), and then "read"ing it again, now showing a bandgap of 0.

The setting in Tools -> display unimplemented config bits has no influence on the behaviour.

The change in the bandgap has been verified by using the command line tool to display the configuration word before and after the actions.

I use application version 2.61, device file 1.61, OS Firmware 2.32.


Can others confirm this bug? It has been reported here before (http://www.microchip.com/forums/tm.aspx?m=452229) but without any replies.

My wish is that
- this bug be fixed
- a method be added (to the GUI and to the command line version) to manually set / override the bandgap setting (a manual setting of the corresponding bits in the Configuration Word would be sufficient, currently these bits cannot be set).

- can the device file be changed such that the programmer software can modify the bandgap bits (mark the corresponding bits in the configuration word as user modifyable)

Kind regards,

Siggi Liese

#1
Ian.M
Super Member
  • Total Posts : 13225
  • Reward points : 0
  • Joined: 2009/07/23 07:02:40
  • Location: UK
  • Status: offline
RE: PICkit 2 loses Bandgap setting of 16F630 when programming 2010/01/23 17:09:04 (permalink)
0

There are some extra settings you can add to PICkit2.ini to

TMEN editable config words etc. See post #34 in 'PICkit 2 FAQ'
Allows the config word (and ID locations) to be edited in HEX (use the menu item: Tools > Test Memory).
Add line:
TMEN:


Another usefull 'tweak' is display silicon revision.
Add line:
REVS: Y


You *should* be able to edit the BOD band gap bits  using 'Test Memory' then reprogram them.

You will need a simple jig to run the PIC from an adjustable supply and a program with BOR enabled that just turns on an output pin to light a LED to detect if it has come out of BOR. You can then test if you have got it back in spec.  If you have another PIC from the same batch, it might be worth checking the bandgap settings on that, but  if not, there are only four possibilities so it shouldn't take long.


#2
holzwurm
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2010/01/23 16:03:30
  • Location: 0
  • Status: offline
RE: PICkit 2 loses Bandgap setting of 16F630 when programming 2010/01/23 17:31:31 (permalink)
0
Hello Ian.M,

unfortunately, your suggestion does not work.
Indeed, the "TMEN" entry in the PICkit2.ini enables the "Tools -> Test Memory" function.
But in the "Test Memory" window any modifications that I do to the (16 bit wide) configuration word are, upon pressing <Return>, automatically modified to retain the lower 9 bits only with the remaining higher bits set to zero including the two most significant bits specifying the bandgap setting.

Regards,

#3
Ian.M
Super Member
  • Total Posts : 13225
  • Reward points : 0
  • Joined: 2009/07/23 07:02:40
  • Location: UK
  • Status: offline
RE: PICkit 2 loses Bandgap setting of 16F630 when programming 2010/01/23 18:37:28 (permalink)
0
It was worth a try. I dont have that PIC so couldn't check if it work.

As the PICKit 2 V2.61 GUI software appears to have BROKEN bandgap config bit handling, I suggest you raise a support ticket with Microchip. 
If/When you get an answer, please follow up here. (Subscribe to this topic, it may be quite some time before you have an answer)

Meanwhile I suggest using another type of programmer!  If you have a dumb bitbanged serial or parallel port programmer, DL4YHF's WinPIC can reprogram bandgap bits if you check 'no special treatment for BG calib' in its 'Options' tab.

If you dont have one, building a Tait 'Classic' LPT port programmer (7407 + PNP transistor type) shouldn't take you more than half an hour if you can scavenge a real 7407 or 74LS07 (needed to tolerate the 12.5 V programming voltage - CMOS 74 series  *wont* work).  With WinPIC it handles a wide range of PICs from the PIC10F, PIC12F PIC16F and PIC18F series that use 12.5 V Vpp.  In the diagram below, RB6 is ICSPCLK/PGC and RB7 is ICSPDAT/PGD and you will need to re-arrange the connections to the PIC socket to suit your PIC.


post edited by Ian.M - 2011/07/29 08:14:41
#4
xiaofan
Super Member
  • Total Posts : 6247
  • Reward points : 0
  • Joined: 2005/04/14 07:05:25
  • Location: Singapore
  • Status: offline
RE: PICkit 2 loses Bandgap setting of 16F630 when programming 2010/01/24 02:46:47 (permalink)
0
No need to go back to an old PIC programmer. grin
As per the following thread, you just need to use an older PICKit 2 programmer version like V2.50. I have not looked into the issue. But I suspect that you can try to use the old Device Data file of V2.50 with V2.61 and maybe it will help.
http://www.microchip.com/forums/tm.aspx?m=452229

  USB_Links and libusb
#5
Ian.M
Super Member
  • Total Posts : 13225
  • Reward points : 0
  • Joined: 2009/07/23 07:02:40
  • Location: UK
  • Status: offline
RE: PICkit 2 loses Bandgap setting of 16F630 when programming 2010/01/24 03:22:41 (permalink)
0
Does V2.50 actually allow the lost bandgap bits to be reprogrammed by the user? If not, a programmer with software that permits this WILL be required to recover the corrupted chips (assuming they aren't being thrown in the trash).

I prefer nicely integrated Microchip tools, but on a weekend with little chance of getting any spares or tools, a solution that can be built in half an hour from junk-box parts *can* have its place.

The programmer I suggested is reliable, handles many PICS that are too old for the PICkit 2 to support like PIC16F84  and can also reprogram the PICkit 2 firmware by ICSP if  the bootloader gets ***ked up so is quite useful to keep around.   It only gets used occasionally but its a great backup if you dont have another Microchip programmer. N.B. due to the fairly high value 10K pullups, if using it for ICSP, use a SHORT cable.  All the 10K resistors can be replaced with 4K7 and the 4K7 ones with 2K2 to improve its drive capabilities.

#6
holzwurm
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2010/01/23 16:03:30
  • Location: 0
  • Status: offline
RE: PICkit 2 loses Bandgap setting of 16F630 when programming 2010/01/24 04:32:48 (permalink)
0
Hello Ian.M,

Your suggestion with the "TMEN" was definitely worth a try. Your suggestion with one of these DIY programmers should be a possible solution (I indeed have a Tait programmer, somewhere ...).

Hello xiaofan,

referring to an older PICkit software will help prevent the loss of bandgap value with future devices. It does not allow to modify the bandgap setting with the already broken PICs.

To all,

By using the PICkit 2 software version 2.55.02, http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en023073 , the bandgap value of a 16F630 seems to be preserved. However, no possibility to override or manually set the bandgap bits is provided with this approach.

Somewhat surprisingly, it seems that I was able to correct both issues. With the aid of Jefferey Post's dat2text utility I was able to decode the PK2DeviceFile.dat and locate the "magic" numbers. With a hex editor I modified two values in the 16F630 section. I did this to the version 1.61 device file supplied with the PICkit software V2.61.

1. Change:
At offset 0x025C6 I changed the old value FF01 to FF31 (this is the bit mask of the configuration word in little endian).
This now includes the two Bandgap bit positions in the bitmask. PICkit 2 Software now correctly preserves the bandgap setting!

2. Change:
In addition to the first change
at offset 0x025C2 I changed the old value 0030 to 0000 (this is the bit mask of the bandgap settings in little endian).
This effectively removes any bandgap handling from the PICkit 2 Software and therefore is not recommended for production programming. HOWEVER, this now leaves the 2 most significant bits in the configuration word user editable and allows to manually change the bandgap bits in the configuration word. Note that manually chaning configuration bits is only possible in PICkit 2 Software V 2.61.


Since the 16F630 is not the only PIC with bandgap setting (AFAIK there are 4 types that have them) the respective changes are probably applicable to these other devices as well.

I consider this a severe bug in the PICkit 2 software, because the ordinary user does not see any clues of the erratic behaviour.
I will try to raise a support ticket at microchip.

Thanks for your discussion. It triggered me in the right way to further analyse and resolve the issue!




#7
xiaofan
Super Member
  • Total Posts : 6247
  • Reward points : 0
  • Joined: 2005/04/14 07:05:25
  • Location: Singapore
  • Status: offline
RE: PICkit 2 loses Bandgap setting of 16F630 when programming 2010/01/24 07:09:36 (permalink)
0
Yes Jeff Post's dat2text is useful to understand the device data file.
Similar PICs are PIC12F629, PIC12F675, PIC16F630 and PIC16F676. They are the first batch of PICs which are supported by PICKit 1 and PICKit 2.

  USB_Links and libusb
#8
FunnyNYPD
Super Member
  • Total Posts : 1553
  • Reward points : 0
  • Joined: 2007/09/28 20:06:59
  • Location: USA & Canada
  • Status: offline
RE: PICkit 2 loses Bandgap setting of 16F630 when programming 2010/01/29 09:17:46 (permalink)
0
Let's know what you got.
#9
gpmendive
New Member
  • Total Posts : 9
  • Reward points : 0
  • Joined: 2005/12/19 06:21:46
  • Status: offline
RE: PICkit 2 loses Bandgap setting of 16F630 when programming 2010/02/01 07:51:38 (permalink)
0
Following the steps detailed  by holzwurm  I further edited the PK2DeviceFile.dat (version 1.61) to solve this issue for 12F629 and 12F675. The entries for these chips are at offsets 0X1EFB and 0x0F40 respectively. 

For the 12F675, adding 0x0023 to the entry offset we get 0xF62, the offset for the bit mask of the bandgap settings wich should be changed from he old value 0030 to 0000 (if you opt to remove any bandgap handling from the PICkit 2 Software). Adding again 0x0004 we get 0x0F66, the offset for the
bit mask of the configuration word, which should be changed from the old value FF01 to FF31.

By the same simple procedure of adding 0x023 and 0x004 we will get the offsets for the 12F629 (0x1F1E and 0x1F22).

Same thing again for the 16F676, in which case, values to be modified are located at 0x2696 and 0x269A.

Thank you all  .
Bill
#10
Ian.M
Super Member
  • Total Posts : 13225
  • Reward points : 0
  • Joined: 2009/07/23 07:02:40
  • Location: UK
  • Status: offline
Re: RE: PICkit 2 loses Bandgap setting of 16F630 when programming 2012/02/23 15:13:47 (permalink) ☄ Helpfulby trevor 2016/06/22 15:47:28
1 (1)
Bumped into this hoary old issue again this month! sad 
Edit : App V2.61 + device file V1.62.14 is  STILL BROKEN and zeros your band gap bits every time you erase or program a PIC12F629,  PIC12F675, PIC16F630 and PIC16F676 without this MANUAL patch!
sadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsad

The required device file dat edits (above) are *MUCH* easier to do with the PICkit 2 device file editor  - so DONT hack the binary directly!

The attached dat file is based on PK2DeviceFile.dat V1.62.14 (the current version as of Feb 2012) but has duplicate entries PIC12F629_BG, PIC12F675_BG, PIC16F630_BG and PIC16F676_BG all with the BandGapMask zeroed and the high nibble of ConfigMasks[0] set to 3 (inline with the above discussion) to remove special bandgap handling and make them normally editable CONFIG bits.   You can only select the edited _BG devices using MANUAL DEVICE SELECT so if you are using autodetect, they are disabled (pure luck the standard device entry is used first - which would be an excellent safety feature if the app wasn't broken sad) so you *COULD* simply replace the standard device file with the hacked one.

USE THE ATTACHED FILE STRICTLY AT YOUR OWN RISK!
RECORD ALL OSCCAL and BANDGAP DATA BEFORE EXPERIMENTING!

Here (lightly edited for the forum)  is what I emailed to my contact that was having difficulties with his PIC12F675 chips:
***********************************************************************
It is possible the bandgap bits in the CONFIG word have also been lost -
Symptoms will be a brown-out reset voltage outside the range BVDD Brown-out Detect Voltage 2.025 — 2.175 V (from datasheet table 12.4).  Vbod (D005) 2.1V typical

My PICs were out of spec and had lost the bandgap bits, resulting in a BOR threshold of about 1.95V. sad Reprogramming the bandgap bits to 1 0 got the BOR threshold back to 2.1V.

To do this, you need a hacked PK2devicefile.dat that lets you read the chip, toggle the formerly hidden bandgap bits in the CONFIG and reprogram. 

Test on a variable bench supply, monitoring the LEDs,  with a test program loaded that has BOR enabled and lights the LEDs. The chip should reset (LEDs goes out) as you decrease the supply voltage past 2.1V and re-illuminate when you increase it again, with both transitions being within the BVDD range above.

N.B. the Pickit 2 adjustable Vdd doesn't go low enough - but if you patch in a silicon diode in series with the Vdd pin and use a DMM to monitor the actual voltage you can test the BOR voltage using the PICkit 2 and even reprogram it like this - though you don't want to leave the diode in permanently and PGC, PGD are likely to be slightly too high to be in spec.

If not, with the app CLOSED, edit PICkit2.ini and add the line:
   
SDAT: Y

which makes the app ask you for the dat file at startup and drop the attached file into your PICkit 2 program directory.
If you select it and use manual device select (on the programmer menu), selecting any midrange device ending _BG overrides the standard settings  to let you edit the bandgap bits (bits 12 and 13 ) in the CONFIG (click the underlined blue Configuration:)

Caution: You MUST NOT use the hacked <device>_BG device selections for normal programming or you will wipe the bandgap bits.
Edit: See bug above!  WRITE DOWN the new value, you WILL need it again

Sequence:
  1. Select 'Manual Device Select' on the programmer menu and also 'Use VPP First Program Entry'  on the tools menu
  2. Select the device PIC12F675_BG
  3.  Read chip or load a HEX file,
  4. Edit CONFIG to set bandgap bits
  5. MAKE SURE THE PICKIT 2 is set for 5V Vdd and [Write] back to the chip and re-test.
  6. Some trial and error may be required, you only have three combinations to retest as if the original was OK you wouldn't be doing this! LoL

DON'T FORGET to remove the SDAT: Y from PICkit2.ini to restore normal operation once all corrupted devices have been reclaimed.
*********************************************************************************************************


HTH

Ian
post edited by Ian.M - 2012/02/23 16:33:53
#11
trevor
Super Member
  • Total Posts : 575
  • Reward points : 0
  • Joined: 2010/05/05 21:02:18
  • Location: The LAN Downunder
  • Status: offline
Re: RE: PICkit 2 loses Bandgap setting of 16F630 when programming 2016/06/22 15:50:46 (permalink)
3 (1)
Just had this issue with a 12F675... and recovered thanks to the Ian's instructions above.
#12
Anobium
Junior Member
  • Total Posts : 47
  • Reward points : 0
  • Joined: 2013/07/15 00:47:49
  • Location: 0
  • Status: offline
Re: RE: PICkit 2 loses Bandgap setting of 16F630 when programming 2018/08/27 06:42:49 (permalink)
5 (1)
Old thread but I will update.
 
PICKitPlus resolves the BANDWGAP issue.  With PICKit Plus you can easily reset the BANDGAP. It is as simple as clicking the text in the user interact 'BandGap'.  Then, Erase or Write.  Simple.
 
See  http://gcbasic.sourceforge.net/Typesetter/index.php/pickitPlus on how to obtain PICKit Plus.
 
Evan
#13
Ian.M
Super Member
  • Total Posts : 13225
  • Reward points : 0
  • Joined: 2009/07/23 07:02:40
  • Location: UK
  • Status: offline
Re: RE: PICkit 2 loses Bandgap setting of 16F630 when programming 2019/02/06 01:33:24 (permalink)
0
It has come to my attention that one of the many forum changes since 2012 has FUBARed the attachment of my post #11 above by stripping its file extension.  It should have extension .zip  and when you rename it to BGrecovery.zip and open it as a zip file, you will find it contains a single file PK2DeviceFile.1.62.14.BG Recovery.dat length 184781 bytes, which is the patcheed .dat file you need.

--
NEW USERS: Posting images, links and code - workaround for restrictions.
I also support http://picforum.ric323.com because this forum is sometimes too broken to use!
#14
Jump to:
© 2019 APG vNext Commercial Version 4.5