# PIC12F675 Programmer using arduino (port from 12bit programmer)

I bought some pic12f675 and i am trying to program it using an arduino (for testing purposes, I was trying to write a simple blinking led code, I tried both my code hex compiled and another that I got on internet).

I looked around and found some pic18f or pic16f sketches, but I used this one for pic12f (the code was made for PIC12F508, which is 12bit, and my pic is PIC12F675, which is 14-bit): http://www.reenigne.org/blog/a-pic12-programmer-from-an-arduino/

The only change I made was to use a 12V battery connected to a TIP102 transistor for the 12V input of the PIC.

One of the hex files I have tried to upload was the one below. I got the hex file general idea: size, address, type, data, checksum. The software I downloaded rejects this hex if I keep the last but one line (:02400E00C43FAD). It says "Address in hex file out of range.". I believe the reason I get this error is because the software was made for 12-bit and the code for 14-bit microcontroller.

:100000000428FF3FFF3FFF3F03138316850107309E
:100010008312990083169F01FF30831285000330FD
:10002000DC00FF30DB00FF30DA00DC0B18281F2873
:10003000DB0B1B281E28DA0B1B28182815288C30F0
:10004000DB00FF30DA00DB0B26282928DA0B262814
:100050002328A130DA00DA0B2B28000085010330B9
:10006000DC00FF30DB00FF30DA00DC0B38283F28F3
:10007000DB0B3B283E28DA0B3B28382835288C3010
:10008000DB00FF30DA00DB0B46284928DA0B462874
:100090004328A130DA00DA0B4B2800000C284F2847
:02400E00C43FAD
:00000001FF


With all that said, assuming that I am correct, I am trying to modify the sofware in arduino to support 14-bit controller (my pic12f675).

And my status on this task: 0%. (almost)

In the arduino source code, which you can find in the first link, then click on github link, file: programmer_c.c. (cant post more than 2 links)

Check the comments at lines 27 to 32.

// Load Data for Program Memory   x x 0 0 1 0     (0 data(14) 0)
// Read Data from Program Memory  x x 0 1 0 0     (0 data(14) 0)
// Increment Address              x x 0 1 1 0
// Begin Programming              x x 1 0 0 0
// End Programming                x x 1 1 1 0
// Bulk Erase Program Memory      x x 1 0 0 1


And here is pic12f675 programming specs (http://ww1.microchip.com/downloads/en/DeviceDoc/41191D.pdf)

The only changes I found was on "Begin Programming" and "End Programming", which was supposed to be:

// Begin Programming              0 0 1 0 0 0
// End Programming                0 0 1 0 1 0


Im not sure how to change it on code yet, but I will find. Even if I fix this, will not resolve the address problem.

If anybody has thoughts or want to help on this port, I would appreciate. Thank you.

## 1 Answer

The algorithms for programming the various PIC microcontrollers differ in confusing little details. As you found out, for the details you must consult the "programming specification" for your target chip.

The line in the hex file you refer to is the Configuration Fuses setting. The address of this thing, and the number of addresses, varies from chip to chip (most 14-bit chips have it at 0x2007). There is a specific command, for the 12F675 xx0000, to go to the start of that area (0x2000). Then you must increment the address 7 time to get to the fuses address, 0x2007.

• interesting, i've got some fuse problems too. your info should give me a head start about what I should change in the code. I will give it a try. I update something later. Thanks
– rtmc
Jan 18 '15 at 21:37
• thank you very much for the information you gave. I was able to write from scratch a software for arduino and programmed the pic. very rudimentar since the hex goes directly into arduino code. but it finally worked. now i can make it better and share later.
– rtmc
Jan 27 '15 at 17:08