Use ESP32 as a PIC programmer?

Thread Starter

spikespiegelbebop

Joined Nov 30, 2021
163
Recently came across this video
which is teaching how to use arduino for programming a PIC microcontroller, but what I'm wondering is if there's a way to achieve that using a ESP32, this one:

1645139581601.png
He said we can use any Arduino board, but I'm not sure if the MCU ESP32 can be considered a type of arduino board. Do you guys know anything about it and have some resources to share?
 

MrSalts

Joined Apr 2, 2020
2,767
An ESP should work, there are no special capabilities that would rule it out other than the esp32 pins are limited to 3v (3.3V) so you'd need a level shifter if you have a 5v pic. But you'll also need the hex file of the program that you want to load into your PIC. And if you have a PIC IDE (MPLAB, for example). Why not grab a cheap Microchip programmer? So much easier.
 

ErnieM

Joined Apr 24, 2011
8,415
Most any micro with sufficient storage to hold the raw program byte code can be used to program a PIC.

Back in the day I made a test fixture with a PIC core to test a product that also has a PIC core. Test zero was for the test PIC to program the product PIC. Microchip published the complete programming spec so there is no need for any guessing games.
 

Jon Chandler

Joined Jun 12, 2008
1,593
If you use the most common "high voltage" programming, you need approximately 12 volts on /MCLR (depends on the PIC version). PICkit programmers use a dc-dc converter to generate this from the ~5V USB supply.

"Modern" computers don't give you direct access to the parallel port or enough voltage to the RS232 port (assuming you can even find a computer with those ports these days) to allow old diy-type programmers to work. There used to be endless discussions of searching for the Holy Grail of USB–parallel port converter that would make this type of programmer work. The consensus seemed to be "this one doesn't work but somebody told me this other one will definitely work" with few people ever finding the prize.

The Microchip ICSP Guide tells you everything you need to know in a mere 264 pages.
 

MrSalts

Joined Apr 2, 2020
2,767
If you use the most common "high voltage" programming, you need approximately 12 volts on /MCLR (depends on the PIC version). PICkit programmers use a dc-dc converter to generate this from the ~5V USB supply.

"Modern" computers don't give you direct access to the parallel port or enough voltage to the RS232 port (assuming you can even find a computer with those ports these days) to allow old diy-type programmers to work. There used to be endless discussions of searching for the Holy Grail of USB–parallel port converter that would make this type of programmer work. The consensus seemed to be "this one doesn't work but somebody told me this other one will definitely work" with few people ever finding the prize.

The Microchip ICSP Guide tells you everything you need to know in a mere 264 pages.
Luckily for the OP, all 264 pages are handled for programming a PIC with an Arduino in the code posted on GitHub. The OP is only asking if ESP32 will work as an arduino.
...and, whether or not "high voltage" is the most common, PICs can be programmed with "low" voltage.
 

geekoftheweek

Joined Oct 6, 2013
1,429
An ESP32 is more than capable of programming a PIC. The same program for the Arduino would probably even work with minimal changes. The biggest change will be how to get the new binary from your PC to the ESP32 instead of to an Arduino.

As mentioned before you will need more parts to do high voltage programming, but luckily low voltage is enabled by default and it's what appears to be in the video (I just scrolled through it quick so hopefully didn't miss anything).

The ESP32 can only do 3.3 volts. The Arduino is probably able to handle 5 volts. You will have to do some level shifting if you want to program 5V parts.

Short answer is yes it can be done.
 

MrSalts

Joined Apr 2, 2020
2,767
The biggest change will be how to get the new binary from your PC to the ESP32 instead of to an Arduino.
Luckily, the ESP can be a web server/access point. If you pick the right code, (SPIFF and HtmlServer) you should be able,to upload the hex-file to the esp without problem. Or, you could upload the file as you program the ESP with your Arduino code. There is a drop down to set the SPIFF file and you may need the spiff library for the esp32. It's been a while since I've played with spiff.
 

MrSalts

Joined Apr 2, 2020
2,767
I've never programmed an IC before. :oops:
I don't know how to start with the ESP32, that's why I asked for some resources, but 264 pages? lol
Then why would you want to figure out how to program an ESP32 to program a PIC? Why not just use the esp32 for whatever you wanted to do with the pic? The esp32 is a microcontroller on a board. I use them all the time. It just takes a usb cable.
 

Thread Starter

spikespiegelbebop

Joined Nov 30, 2021
163
Then why would you want to figure out how to program an ESP32 to program a PIC? Why not just use the esp32 for whatever you wanted to do with the pic? The esp32 is a microcontroller on a board. I use them all the time. It just takes a usb cable.
I'll kiss your a** if you tell me how to use the ESP32 in this project, replacing the ICs with it. hahahah
 

ErnieM

Joined Apr 24, 2011
8,415
EZ PZ. Remove IC2 A & B, replace with a jumper 2 to 3 and another 5 to 6.

Replace the PIC (IC1) with a mixture of 78% nitrogen, 21% oxygen, 0.3% carbon dioxide and 0.7% of other gases, any additional H2O may be also added.

And don't use a sync rate higher than 17khz.
 

MrSalts

Joined Apr 2, 2020
2,767
EZ PZ. Remove IC2 A & B, replace with a jumper 2 to 3 and another 5 to 6.

Replace the PIC (IC1) with a mixture of 78% nitrogen, 21% oxygen, 0.3% carbon dioxide and 0.7% of other gases, any additional H2O may be also added.

And don't use a sync rate higher than 17khz.
I was just texting my brothers about a non-problem "problem" that my mother had thought about long and hard to develop an awkward solution. I am going to steal your proposed solution IRT 78%N2, 21%O2...
 

geekoftheweek

Joined Oct 6, 2013
1,429
Luckily, the ESP can be a web server/access point. If you pick the right code, (SPIFF and HtmlServer) you should be able,to upload the hex-file to the esp without problem. Or, you could upload the file as you program the ESP with your Arduino code. There is a drop down to set the SPIFF file and you may need the spiff library for the esp32. It's been a while since I've played with spiff.
Never thought of that route. I have a few ESP8266 based creations so far all based on custom sockets. I still have not tried the servers from the Arduino IDE. A PIC programmer is on the list sooner or later. I already have a few programs for my PI to program some parts I did just for fun. It won't take much to convert them over.
 
Top