Author Topic: ZEPPP: Arduino-based PIC programmer for several old-school microcontrollers.  (Read 15681 times)

0 Members and 2 Guests are viewing this topic.

Offline panoss

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: gr
So you 're saying that actually Arduino is not even necessary for this job?
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 2794
  • Country: ca
So you 're saying that actually Arduino is not even necessary for this job?

All you need is to produce logic levels on 3 (or 4 for PICs with PGM pin) pins. If you want to detect if the PIC is connected or to verify the results, one of the lines must be bi-directional.
 
The following users thanked this post: amyk, panoss

Offline panoss

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: gr
So let 's say I have a 16F628A.
Using the 'PIC16F627A/628A/648A EEPROM Memory Programming Specification'  I will try to make the algorithm for entering LVP mode (Low Voltage Program).

The 4 pins that should be used are PGM(RB4), MCLR(RA5), DATA(PGD (RB7)) and CLOCK(PGC (RB6))? 

Page 6: ' Low  voltage  Program/Verify  mode  is  entered  by  raising  VDD,  then  MCLR and PGM, as shown in Figure 2-3'
Code: [Select]
Enter Low voltage Program/Verify mode:
1. supply PIC with power
2. PGM must be set to HIGH
3. MCLR must be set to HIGH
Is my pseudocode correct?
How much time should pass between these commands? Where can I find this?





« Last Edit: January 07, 2020, 05:21:35 pm by panoss »
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 2794
  • Country: ca
How much time should pass between these commands? Where can I find this?

In Section 4 (table 4-1 "AC/DC CHARACTERISTICS TIMING REQUIREMENTS FOR PROGRAM/VERIFY
MODE") of your programming document.
 
The following users thanked this post: panoss

Offline panoss

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: gr
How about this:
Code: [Select]
Enter Low voltage Program/Verify mode:
1. supply PIC with power
2. Wait for 5us  (Hold time after VDD↑ 5us)
3. PGM must be set to HIGH
4. MCLR must be set to HIGH
5. Wait for 5us  (Hold time after MCLR↑ 5us)
6. Wait for 5us (Hold time after LVP↑ 5us)
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 2794
  • Country: ca
How about this:
Code: [Select]
Enter Low voltage Program/Verify mode:
1. supply PIC with power
2. Wait for 5us  (Hold time after VDD↑ 5us)
3. PGM must be set to HIGH
4. MCLR must be set to HIGH
5. Wait for 5us  (Hold time after MCLR↑ 5us)
6. Wait for 5us (Hold time after LVP↑ 5us)

I think the LVP wait time comes between PGM up and MCLR up. In practice, the only important thing is to make sure to set PGM before MCLR - otherwise the PIC will start running and may screw everything up.
 
The following users thanked this post: panoss

Offline battlecoder

  • Regular Contributor
  • *
  • Posts: 95
  • Country: cl
    • A BIT of Mystery
Hi battlecoder, thanks for sharing your work.
I 'm trying to understand your code and how e.g. from the 'PIC16F627A/628A/648A EEPROM Memory Programming Specification' you created the code you created.
(because I want to be able to do the same for any MCU or EEPROM and specifically for an EEPROM I have(EN25F80))

I read in the above mentioned document, page 11:
Quote
To perform a Bulk Erase of the program memory, the following sequence must be performed:
1.Execute a Load Data for Program Memory with the data word set to all ‘1’s (0x3FFF).
2.Execute   a   Bulk   Erase   Program   Memory   command
3.Wait TERA for the erase cycle to complete.

From this you created this code:
Code: [Select]
ReturnCode execute_serial_cmd() {
switch (cmdCode) {
// PGM Memory Erase --------
    .................
    case ZEPPP_CMD_PGM_MEM_ERASE:
      load_pgm_mem (0x3fff); 
      bulk_erase_pgm_mem();   

Am I correct?
Yep. Tried to follow the programming specifications as much as possible, but when i found differences between devices I normally checked if one of the methods also worked on the other devices first, before having device-specific implementations of a particular process.

A set of wires connected to a PC parallel port will do LVSP just as well.
In fact the first programmer I built for myself used the parallel port! It required several components, but they were mostly for the HVP part. LVP can totally be done with nothing but the LPT port. It's unfortunate that it's not a popular port nowadays and computers no longer have it.

So let 's say I have a 16F628A.
Using the 'PIC16F627A/628A/648A EEPROM Memory Programming Specification'  I will try to make the algorithm for entering LVP mode (Low Voltage Program).

The 4 pins that should be used are PGM(RB4), MCLR(RA5), DATA(PGD (RB7)) and CLOCK(PGC (RB6))? 

Page 6: ' Low  voltage  Program/Verify  mode  is  entered  by  raising  VDD,  then  MCLR and PGM, as shown in Figure 2-3'
Code: [Select]
Enter Low voltage Program/Verify mode:
1. supply PIC with power
2. PGM must be set to HIGH
3. MCLR must be set to HIGH
Is my pseudocode correct?
How much time should pass between these commands? Where can I find this?
As NorthGuy already mentioned, all the information is in the programming specs.
If you are able to generate the signals with the appropriate timing, yeah, you don't need An arduino. You could use a Raspberry Pi, a PC with a Parallel port, a Wemos board, whatever allows you to create logic-level signals according to the specs.
My project uses an Arduino to create the signals because they are simple, cheap, and can be connected to a computer via USB, which is a port you will find in any computer built after the Stone Age. :)
 
The following users thanked this post: panoss

Offline mcovington

  • Regular Contributor
  • *
  • Posts: 138
  • Country: us
I like the name ZEPPP, which suggests you once encountered NOPPP, which I was the perpetrator of, about a quarter century ago!
 
The following users thanked this post: battlecoder

Offline battlecoder

  • Regular Contributor
  • *
  • Posts: 95
  • Country: cl
    • A BIT of Mystery
I like the name ZEPPP, which suggests you once encountered NOPPP, which I was the perpetrator of, about a quarter century ago!
!!! Indeed! The name of my project is 100% an homage to both the original NOPPP, and the "Enhanced" version based on your design, which ended up being the first PIC programmer I built and used! Your NOPPP programmer is what allowed me to begin my journey with microcontrollers when I was (way) younger!
 
The following users thanked this post: mcovington

Offline mcovington

  • Regular Contributor
  • *
  • Posts: 138
  • Country: us
For completeness we must acknowledge David Tait's TOPIC (Try Out PIC), of which NOPPP was a simplification.  A long lineage!
 

Offline battlecoder

  • Regular Contributor
  • *
  • Posts: 95
  • Country: cl
    • A BIT of Mystery
For completeness we must acknowledge David Tait's TOPIC (Try Out PIC), of which NOPPP was a simplification.  A long lineage!
Oh, definitely. David Tait was a name that kept appearing in my searches when I started with PICs. There were a few other names that were really everywhere, and people around the world were building those designs and improving upon them. JDM was also another popular programmer circuit back then, and NOPPP was also 100% part of that landscape.

Back then I had pretty basic "maker" skills, almost no knowledge, and highly limited access to electronic components and tools, so the simpler the circuit the better.
I ended up building James Padfield's modified version of NOPPP, though, which (if my memory serves me well) was fairly "recent" at the time, and supported a couple more PICs by means of a simple extra resistor and modified software.

I owe you a lot, truly. Even when NOPPP was simple in its design I learned a lot from it, and it remained my only and trusted tool for programming PICs for at least several years after I built mine.
 
The following users thanked this post: mcovington

Offline Slothie

  • Regular Contributor
  • *
  • Posts: 66
Re: ZEPPP: Arduino-based PIC programmer for several old-school microcontrollers.
« Reply #36 on: September 18, 2020, 03:22:55 pm »
Ah PC Paralell Port - thats a name I haven't heard in years! :)
 

Offline Slothie

  • Regular Contributor
  • *
  • Posts: 66
Re: ZEPPP: Arduino-based PIC programmer for several old-school microcontrollers.
« Reply #37 on: September 20, 2020, 06:53:56 pm »
I've just used this to successfully program a PIC 16F877A with an Arduino Uno using Linux Mint 20 and java 11. I did have problems getting the arduino sketch to compile until I moved the two typedef's into a seperate .h file. Not sure why this was because I'm not an Arduino expert, but  I googled and that seemed to be the suggestion people made. Perhaps it was a change to the Arduino pre-processor that reformats the .ino files.  :-//
 
The following users thanked this post: battlecoder

Offline battlecoder

  • Regular Contributor
  • *
  • Posts: 95
  • Country: cl
    • A BIT of Mystery
Re: ZEPPP: Arduino-based PIC programmer for several old-school microcontrollers.
« Reply #38 on: September 22, 2020, 06:49:52 pm »
I've just used this to successfully program a PIC 16F877A with an Arduino Uno using Linux Mint 20 and java 11. I did have problems getting the arduino sketch to compile until I moved the two typedef's into a seperate .h file. Not sure why this was because I'm not an Arduino expert, but  I googled and that seemed to be the suggestion people made. Perhaps it was a change to the Arduino pre-processor that reformats the .ino files.  :-//

I will look into the issue you found. I have to admit I haven't updated my Arduino environment in a long, long time, so it could be that the code is not really compiling with later versions of the Arduino environment and I'm just finding out now thanks to you. I have encountered errors like that in the past in other people's projects (that probably used to compile fine 3 years ago but now suddenly you need to rename stuff, or move some declarations somewhere else), so it wouldn't surprise me to see that kind of problem in one of my projects.

Anyway, glad to hear you were able to use this programmer successfully. I quite liked the 16F87x family of PIC micros back in the day, and in fact I think the "brain" of my first robot was a 16F874, if my memory serves me right.
 

Offline alexblade

  • Newbie
  • Posts: 3
  • Country: md

I made similar programmer for newer 8-bit devices - https://github.com/jaromir-sukuba/a-p-prog - and really didn't bother to support the older ones (with PGM pin), so your work is great addition to simple PIC programmers.
Hi! 
I am interested in your project. Please tell me you have implemented the ability to read the firmware?
if not. could you do it in the next version 1.0 ?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf