Arduino as a Pic Programmer!

How can the Read software be saved?

Not implemented yet but you can still copy/paste the text from the output window...
Does reading work for you?

Hey, just wanted to give you two thumbs up for this project!
I've spent some time looking for a way to program pic through arduino and only found some (pretty arrogant) guys saying that it's not possible.. I wanted to make a PicKit2 clone, but needed something to burn hex to 16f2550, and it seems that your solution is exactly what I was looking for. It's unfortunate that I won't have time to try it soon, but keep up the good work!

Hey Sorraine,
This is a nice project. Does this work for PIC24 (PIC24FJ256GA110) ?

Hi, Soranne !

As I said on the french topic of your project - http://arduino.cc/forum/index.php/topic,93067.0.html - I'm trying to reproduce the same kind of project with a PIC18F2550.
When i'll finish it, i'll share it on this topic, attached with a report. I expect that will help everybody else to adapt this project to their favorite microcontroller.

Cordially,

Watchi~

Very interesting project!

Ditto... must keep an eye on this as my Pic programmer uses serial and my new PC doesn't... :wink:
Keep it up Soranne, nice project...
Mike

Hi, watchinofoye

I was also trying to build an Arduino PIC programmer for the PIC18F2550. So far without much success.

Here is my code:

/* 
 * Trying to build an arduino pic programmer for the PIC18F2550
 * Programming specifications: http://ww1.microchip.com/downloads/en/DeviceDoc/39622L.pdf
 * Author: Ingmar Jager
 */
 
//Pin layout
int pgc = 9;  // program clock
int pgd = 8;  // program data
int pgm = 10;  // program mode
int MCLR = 11; //Master Clear Reset / Vpp

void setup()
{
  Serial.begin(9600);
  
  pinMode(pgc, OUTPUT);
  pinMode(pgd, OUTPUT);
  pinMode(pgm, OUTPUT);
  pinMode(MCLR, OUTPUT);
  delay(500);
  
  enterProgramming();
  delay(500);
  tableRead(0x3F, 0xFF, 0xFF);
  delay(500);
  tableRead(0x3F, 0xFF, 0xFF);
  exitingProgramming();
}

/*
 * @param: three bytes which form the tablepointer address
 */
void setTablePTR(int addr_upper_byte,int addr_half_byte,int addr_lower_byte)
{
  
 Serial.print("Set TablePTR to: 0x");
 Serial.print(addr_upper_byte, HEX);
 Serial.print(addr_half_byte, HEX);
 Serial.println(addr_lower_byte, HEX);
 
 writeBits(4, 0x0); // 4 bit command
 writeBits(16, 0x0E00 + addr_upper_byte); // 16 bit data payload: load address
 writeBits(4, 0x0); 
 writeBits(16, 0x6EF8);  // set TBLPTR_U to addr_upper_byte
 
 writeBits(4, 0x0);
 writeBits(16, 0x0E00 + addr_half_byte);
 writeBits(4, 0x0);
 writeBits(16, 0x6EF7); //TBLPTR_H
 
 writeBits(4, 0x0);
 writeBits(16, 0x0E00 + addr_lower_byte);
 writeBits(4, 0x0);
 writeBits(16, 0x6EF6); //TBLPTR_L
  
}
/*
 * Read byte from the given address
 */
void tableRead(int high_byte, int mid_byte, int low_byte)
{
  
  setTablePTR(high_byte,mid_byte,low_byte);
  
  writeBits(4, 0x8); //1000 = Read and no increment
  writeBits(8, 0x00);
  pinMode(pgd, INPUT);
  delayMicroseconds(5); //P6 
  
  byte data = 0;
  //actual read
  Serial.print("Read bits from LSB to MSB: ");
  for (int i = 0; i < 8; i++)
  {
    digitalWrite(pgc, HIGH);
    delayMicroseconds(3); //P14 
    
    if (digitalRead(pgd)==HIGH)
    {
      Serial.print("1");
      data += (1 << i);
    }
    else
    {
      Serial.print("0");
    }
      
    digitalWrite(pgc, LOW);
        delayMicroseconds(3); 
  }  
  
  delayMicroseconds(5); //P5A
  pinMode(pgd, OUTPUT);
  Serial.println();
  Serial.print("Reading result: ");
  Serial.println(data);
}
  
/* Write LSB to MSB
 * @param n = number of bits to write
 * @param value = value to write in n bits
 */
void writeBits(int n, int value)
{
  digitalWrite(pgc, HIGH);
  for (int i = 0; i < n; i++) {
     if( (boolean) ((value >> i) & 1))
        digitalWrite(pgd,HIGH);
  }   
  delayMicroseconds(3);
  digitalWrite(pgc, LOW);
  delayMicroseconds(3);
  digitalWrite(pgd,LOW);
  delayMicroseconds(5); //P5A
} 

/*
 * Entering low voltage programming signals
 */
void enterProgramming()
{
   digitalWrite(pgc, LOW);
   digitalWrite(pgd, LOW);
   digitalWrite(pgm, LOW);
   digitalWrite(MCLR, LOW);
   
   delayMicroseconds(20);
   
   digitalWrite(pgm, HIGH);
   delayMicroseconds(3);//P15
   digitalWrite(MCLR, HIGH);
   delayMicroseconds(3);//P12
   Serial.println("Entered Low Voltage Programming");
}

/*
 * Exiting low voltage programming signals
 */
void exitingProgramming()
{
   digitalWrite(pgc, LOW);
   digitalWrite(pgd, LOW);
   delayMicroseconds(1); //P16
   digitalWrite(MCLR, LOW);
   delayMicroseconds(1); //P18
   digitalWrite(pgm, LOW);
   Serial.println("Exiting Low Voltage Programming");
}


void loop()
{
 
}

I'm trying to read the deviceID on address 0x3FFFFF. According to the programming specifications the DEVID1 = 010x xxxx and DEVID2 = 0x12.
When I run my program, this is the output:

Entered Low Voltage Programming
Set TablePTR to: 0x3FFFFF
Read bits from LSB to MSB: 00000000
Reading result: 0
Set TablePTR to: 0x3FFFFF
Read bits from LSB to MSB: 00011111
Reading result: 248
Exiting Low Voltage Programming

So the first time I try to read the ID register it returns 0. However the second time the result is 00011111 (248). If I read it a third time it is 0 again. So I'm not quite sure what is happening here.

Have you got some better results?

I have been having issues with the GUI version.
When I Burn a hex to the pic, it seems to work (tx light on usb adapter flashes, etc) and the program says "Finished!" after a short time.
However, when I hit "Read from PIC" all lines (0-49) say 00000000000000

I'm using a PIC16F628A

ive been looking for something like this for a long time; great work!

I wrote a similar sketch for the PIC18F2550 ( a slight modification can adopt it to almost all pic18F2/4 family). the sketch and the instruction can be found over here:

Hi soranne,

sorry, I don´t speak english very good

I know how to get 12V from USB port, There are two ways:

1.-With a coil and a zenner

2.- With capacitors, Diodes and a zenner

the first option are more easy but it is more difficult to get the coil.

I will post here how to make

reggards.

I wrote a similar sketch for the PIC18F2550 ( a slight modification can adopt it to almost all pic18F2/4 family). the sketch and the instruction can be found over here:

https://sites.google.com/site/thehighspark/arduino-pic18f

Damn ! Project already done !
Well, I'll still try to do it, at least to understand the ICSP method and achieve implementation by myself.
But, even so I am disgusted ! >.< I was caught up again ! Just my luck !

Hey all! sorry for answering so late but I have been busy with a lot of homework :s
I have to say I am not sure I will be able to work again on this project because it involves a lot of time (coding a programming method for nearly every pic!).
What Is suggest is that someone who is really motivated gathers all the programming methods for each pic to make one nice prog.

Hope I can help again!

hi soranne where i can find your program c# to load pic?
also what is latest state your project?

and soranne your project page (https://sites.google.com/site/thehighspark/arduino-pic18f ) is broken
is there any alternatif link??

Dear mahk,

I am sorry this page is not my project.

hey soranne can you give me alink for this project(circuit,program)
i need this project for my thesis in school

All the infromation I have is on the first page

Hi!

A good project!
In case interested, I've created an Arduino programmer for PIC32 series. The details are found at Google Code Archive - Long-term storage for Google Code Project Hosting..

Cheers!