read from PIC12F508 "configuration memory" (e.g. Backup OSCCAL...) - Page 1
Forum section: electronics / general

author: JeanF
author_rank: Regular Contributor
timestamp: September 29, 2021, 11:29:57 am
content: Hello,I can easily read the Program Memory of the PIC (000h to 1FFh on the 12F508) with many tools (MPLABX IDE or IPE, Pickit3 standalone tool, and surely many others)according to theMemory Programming Specificationfor this chip there is a Configuration Memory Space from 200h to 3FFh.do you know any practical way of reading data from there ? I'd like to read address 204h specifically, which is the backup OSCCAL value. (Not sure if it's still there, that's why I'd like to have a look)Maybe there is some custom software to do this with a PICkit ? I have a genuine PK3 but a PK2 clone is on the way. Or another programmer, please let me know. Or maybe with an Arduino, or a Bus Pirate... There must be something ! But my Google skills weren't up to the task this time.The memory programming spec above gives all the details, timings, protocols, etc. but I don't want to reinvent the wheel if possible.Thank you!A bit more context (if needed)- I'm a beginner with PICs, there are several (vintage) projects on the web that I wanted to learn from but they were written in asm, which i know nothing of. So I decided to follow the first (baseline) Gooligum tutorial to get my feet wet.- I struggled with different versions of MPLAB, MPLABX, PICkit3 standalone tool, PICkit3 firmware etc. and somehow I managed to corrupt the "main" OSCCAL value at 1FFh- I know that PK2 included a way to recalibrate ; I can also calibrate by hand with a frequency counter and put a proper value at 1FFh with PK3 standalone tool... Or just get a new chip... This is not really a calibration problem, it's mainly about improving my knowledge!- Some will say "you shouldn't use this ancient chip", or "why are you bothering with ASM"... go ahead, I'm prepared!Appendix12F508 datasheet

author: Ian.M
author_rank: Super Contributor
timestamp: September 29, 2021, 06:55:47 pm
content: For PICkit 2 using its standalone GUI software, see:https://www.microchip.com/forums/m455103.aspxAs the PICkit 3 standalone software was developed from the PICkit 2 software, the same method may also be applicable. YMMV

author: JeanF
author_rank: Regular Contributor
timestamp: September 30, 2021, 10:03:42 am
content: Thanks, I wasn't aware of this "test memory" hidden feature.I was able to read the config memory with a PICkit3 and its standalone GUI v3.10. As you mentioned on the Microchip forums (link above) its needed to add "TMEN:" (without quote marks) in PICkit3.ini, then the "test memory" option appears in the Tools menu. Also the PICkit3 has to be programmed with the "standalone" OS, if its in MPLAB mode the "test memory" feature doesn't show up even with the modified .iniNotes :- it's necessary to open the "test memory" window before clicking "Read" in the main window, otherwise the "test memory" window appears blank (filled with FFF) even though the memory on the chip isn't blank- At first I had the software installed in my C drive but there was no PICkit3.ini in the folder; the executable has to run at least once in Administrator mode to be able to create the INI file. Alternatively its possible to install the software in D drive...- on a brand new chip, the reading method above indeed shows the backup OSCCAL value at address 204h (12F508) or 404h (12F509) which is obviously the same as the primary OSCCAL value at 1FFh or 3FFh, as well as some random bits in the reserved area (used by Microchip during manufacturing maybe?)- Erasing the chip with PICkit3 GUI will erase everything except the main OSCCAL value (at 1FFh on the 12F508). The backup OSCCAL value will be erased.- programming the chip with MPLABX (in my case v5.2) will preserve the two values of OSCCAL (primary and backup).Thank you PeDre for the tip about MikroE programmers. I don't plan to use your code right now because I already recalibrated my 12F508 with a simple ASM loop that toggles a pin and a frequency counter, but it could be useful for some people! Is your code online somewhere, or maybe could you attach it here?Apparently the programmer made by Alberto Maccioni athttp://openprog.altervista.org/OP_eng.htmlcould also work to retrieve a lost OSCCAL value. There are options in his command-line utility such as -use_BKosccal (to copy BKosccal to osccal) or -r to read reserved area.