Author Topic: read from PIC12F508 "configuration memory" (e.g. Backup OSCCAL...)  (Read 1180 times)

0 Members and 1 Guest are viewing this topic.

Offline JeanFTopic starter

  • Regular Contributor
  • *
  • Posts: 142
  • Country: fr
read from PIC12F508 "configuration memory" (e.g. Backup OSCCAL...)
« on: September 29, 2021, 11:29:57 am »
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 the Memory Programming Specification for 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" :D ... go ahead, I'm prepared!  :popcorn:

Appendix

12F508 datasheet
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12753
Re: read from PIC12F508 "configuration memory" (e.g. Backup OSCCAL...)
« Reply #1 on: September 29, 2021, 06:55:47 pm »
For PICkit 2 using its standalone GUI software, see: https://www.microchip.com/forums/m455103.aspx

As the PICkit 3 standalone software was developed from the PICkit 2 software, the same method may also be applicable.  YMMV
 

Offline JeanFTopic starter

  • Regular Contributor
  • *
  • Posts: 142
  • Country: fr
Re: read from PIC12F508 "configuration memory" (e.g. Backup OSCCAL...)
« Reply #2 on: September 30, 2021, 10:03:42 am »
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 .ini

Notes :

- 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 at http://openprog.altervista.org/OP_eng.html could 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.

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf