Introduction: PIC 12F675 Programmer/OscCal Restore/Tester

Picture of PIC 12F675 Programmer/OscCal Restore/Tester

One of my circuits that I build quite often (20 - 40 at a time), uses a PIC 12F675. I had the following issues:

  • The boards that I make, does not have in-circuit programming capabilities. This is to allow for a small PC board layout. PICs thus need to be programmed out of circuit.
  • I only have a PICkit 3 programmer, which does not have a convenient ZIF socket to program a stand-alone PIC. To program a PIC, I have to set up a circuit on breadboard.
  • To test the programmed PIC, and set certain parameters, the circuit still needs to be on a breadboard.
  • To test the circuit, external equipment is needed (Servo tester, 5V BEC, 3 cell LiPo battery, and the load driven by the circuit.
  • Sometimes, the PICkit 3 erases the calibration bit on the PIC. This prevent my circuit from working. To reprogram the calibration bit, another circuit is needed to determine the correct calibration bit.

This board started as a tool to speed up the calibration bit programming on the PIC 12F675 without the need for additional components or wires.

Soon, I realised that the same circuit can also be used to upload hex files to a PIC.

Finally, with a screen and 2 buttons, I added a test routine to the same circuit, so that I can adjust the parameters, and perform an operational test of the final software on the PIC.

The final board now performs the following functions::

  • Programming of a PIC using a PICkit
  • Calculating and programming of the calibration bit of the PIC
  • Testing of a PIC final software and parameters.

Step 1: The Circuit

Picture of The Circuit

An ATMEGA328p is used as interface to the PIC 12F675,

Power to the PIC is controlled by the ATMEGA.

All pins of the PIC, apart from the reset pin, can be controlled via the ATMEGA.

The PICkit header pins allow for easy connection of the PICkit programmer to the circuit, and allows for a quick way to read/program the PIC.

The on-board screen is used for selection and display of steps and statuses.

Three buttons allow for menu navigation and parameter setup.

The ATMEGA can be programmed in circuit via the 6 pin ICSP headers.

Step 2: The PC Board

Picture of The PC Board

All components required, are mounted onto the PC Board.

Because the PICkit can not deliver enough power to drive the ATMEGA328p and LCD display, power for the circuit is obtained via a USB cable.

Assembly of the board is simple, and uses only through-hole components.

Once the PC Board is assembled, you can program the ATMEGA328p via the on-board ISCP headers.

All files required for the project, are attached.

Step 3: Using the Board

Picture of Using the Board

To use the board, follw these steps:

  • To power the board, connect a standard USB cable between the board and computer.
  • Connect the PICkit programmer to the headers, and to the computer.
  • Open MPLab.
  • Select PICkit as programmer.
  • Select PIC 12F675 is device.
  • From the menu on the screen, select the required option.
  • Follow the on-screen instructions.

Step 4: Programming a PIC 12F675

Picture of Programming a PIC 12F675

Follow the step:

  1. From the menu, select "Pgm PIC"
  2. The menu selection will be displayed briefly on the screen.
  3. You will be asked to insert a PIC. Press Ok after PIC is inserted.
  4. The next screen will prompt you to program the PIC.
  5. During this step, power to the PIC is turned on.
  6. In MPLab, load your file/project.
  7. Select programmer as PICkit.
  8. Upload program to chip.
  9. When done, press Ok.
  10. Power to the PIC is turned off at this stage.
  11. You will be asked to insert a PIC.
  12. It is now save to remove the PIC. Repeat for next PIC if required.

To exit the programming mode, press Up or Down button when asked to insert 12F675.

Step 5: Determine the Calibration Bit

Picture of Determine the Calibration Bit

Follow the step:

  • From the menu, select "Pgm Osc"
  • The menu selection will be displayed briefly on the screen.
  • You will be asked to insert a PIC. Press Ok after PIC is inserted.
  • Program the PIC with "OscCal.hex" This file needs to be loaded onto the PIC to determine the value of OSCAL.
  • During this step, power to the PIC is turned on. In MPLab, import the file "OscCal.hex".
  • Select programmer as PICkit.
  • Upload program to chip.
  • When done, press Ok.
  • Power to the PIC is still on at this stage.
  • A 1000Hz test signal will be generated by the PIC. During this step, the PIC will be controlled by the ATMEGA to determine the OSCAL value closest to 1000Hz.
  • When done, the correct value of OSCAL will be displayed.
  • Program this new OSCCAL value into the calibration bit of the PIC.
  • When done, press Ok.
  • Power to the PIC is turned off at this stage.
  • You will be asked to insert a PIC.
  • It is now save to remove the PIC. Repeat for next PIC if required.
  • If the correct file (OscCal.hex) is not loaded, PIC not Found message will be displayed.

To exit the calibration mode, press Up or Down button when asked to insert 12F675.

Step 6: Programming New Calibration Bit in MPLab

Picture of Programming New Calibration Bit in MPLab

When the screen displays the newly found OscCal value, do the following:

  • In MPLab, open the EEPROM view.
  • Read the PIC.
  • The last two lines will contain the the OSCAL details.
  • Memory location 0x6F will contain the OSCAL value stored on the PIC if it was not erased. There is no need to program the new calibration bit. Press Ok to continue.
  • Memory location 0x7F will contain the calculated new OSCAL value. This is the value of the calibration bit that needs to be set in MPLab.
  • Open the Setting window, and select Calibration Memory.
  • Select "Allow PICkit to program calibration memory".
  • Enter the new calibration value as displayed on the screen. Apply changes.
  • Next, program the file "OscCal.hex" file again to the PIC.
  • MPLab will warn that it is about to program new calibration data to the PIC. Select YES.
  • Your PIC calibration data has now been restored.
  • When done, press Ok.
  • Power to the PIC is turned off at this stage.
  • You will be asked to insert a PIC.
  • It is now save to remove the PIC.
  • Repeat for next PIC if required.

To exit the calibration mode, press Up or Down button when asked to insert 12F675.

Step 7: Testing of PIC 12F675 - Specific Circuit

Picture of Testing of PIC 12F675 - Specific Circuit

NOTE:

This part is a demo of what the Test menu does. This testing is done for a specific function, and the user can change the test sequence by editing the ATMEGA328p file.

This part of the board test a programmed PIC for correct parameters. The "PicTest.hex" must be loaded into the PIC for this to work.

The ATMEGA is used to simulate a signal on one of the PIC pins. It then test the correct operation by comparing the input signal to outputs on a PIC pin.

Follow the step:

  • From the menu, select "Test R/C"
  • The menu selection will be displayed briefly on the screen.
  • You will be asked to insert a PIC.
  • Press Ok after PIC is inserted.
  • During this step, power to the PIC is turned on.
  • The next screen will display the test status.
  • When the test is done, and program works correct, PIC Passed will be displayed briefly on the screen, followed by the test results.
  • When the test fail, PIC Failed and a corresponding error code will be displayed.
  • When done, press Ok.
  • Power to the PIC is turned off at this stage.
  • You will be asked to insert a PIC.
  • It is now save to remove the PIC.
  • Repeat for next PIC if required.

To exit the test mode, press Up or Down button when asked to insert 12F675.

Comments

mivid (author)2017-09-22

THIS IS WHAT I CALL INSTRUCABLE, EXACTLY WHAT I NEEDED

Eric Brouwer (author)mivid2017-10-09

Thank you for your feedback.

Regards

Eric

Omnivent (author)2016-02-20

That's a whole lot of components for this simple task!

While I know there's been some issues with the PICKit-3, I'd think that it could do it on it's own (like the PICKit-2 can)?

Otherwise, take a look at:

http://picprojects.org.uk/projects/recal/recal.htm

for a simpler and cheaper way of doing it - and remember to mark the calibration word on the chip (e.g. a dot over each pin for "1" and nothing for "0"), after initial read (before programming anything at all).

Have a nice day :)

mivid (author)Omnivent2017-09-22

if you have read the title of this instructable ( PIC 12F675 Programmer/OscCal Restore/Tester ) you would know tha your comment was inappropriate

rafununu (author)Omnivent2016-02-22

Thanks a lot. You made me discover a simple and reliable way to get this word my f..... ICD3 overburned. As it was a decade ago I simply chose to work with another model of PIC.

Thanks Eric but you'll admit you've build a supercharged board !

Eric Brouwer (author)rafununu2016-02-23

I agree it was an super-zoom-zoom-deluxe project when it was started. But now it is used to perform 3 independent functions which I previously had to do on 2-3 separate breadboard circuits.

I thing you will now agree that this board was worth the effort put into it.

Eric Brouwer (author)Omnivent2016-02-20

I agree with you about the number of components.. But I wanted a self-contained unit that I could do every thing without moving the PIC between a calibration board, programming board, and the final product.

I build a lot of R/C switches (https://www.instructables.com/id/RC-Controlled-Swit...) which, due to the small PC board, does not have ICSP pins.

Additionally, I wanted to be able to remove the power from the PIC during the different steps, without switching on/off power supplies.

A big part of this specific circuit was left out from this instructable. This circuit is used to program my final PIC programs as well, and to set up the different parameters for the final product. The ATMEGA328p is used for testing the final circuit before the PIC is soldered to the final product.

Janaka1982 (author)2016-03-22

good work

Eric Brouwer (author)Janaka19822016-03-23

Thanks for your feedback.

Mic100 (author)2016-02-21

very interesting for me Thank you

Eric Brouwer (author)Mic1002016-02-23

Thank you.