Pages: 1 2 [3] 4 5 6   Go Down
Author Topic: Arduino as a Pic Programmer!  (Read 80502 times)
0 Members and 2 Guests are viewing this topic.
ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1619
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok that is fine.
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

France
Offline Offline
Jr. Member
**
Karma: 3
Posts: 72
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Updated C# code and arduino code, should work with many pics (doesn't support config word yet...).

Don't forget to reset PIC before reading/writing. If the prog says "access to COMX denied", just close and re-open the prog.
« Last Edit: March 03, 2012, 12:54:03 pm by Soranne » Logged

My projects :
- Interfacing with Minitel : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1271350467
- Arduino PIC programmer : http://ardu

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1619
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks! i will get back to you with the results.
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

France
Offline Offline
Jr. Member
**
Karma: 3
Posts: 72
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok! smiley
I'm not sure about writing, but reading should work fine smiley-wink
Logged

My projects :
- Interfacing with Minitel : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1271350467
- Arduino PIC programmer : http://ardu

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1619
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How can the Read software be saved?
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

France
Offline Offline
Jr. Member
**
Karma: 3
Posts: 72
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

My projects :
- Interfacing with Minitel : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1271350467
- Arduino PIC programmer : http://ardu

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Caen, France
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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~
Logged

Parma
Offline Offline
Edison Member
*
Karma: 21
Posts: 2421
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Very interesting project!
Logged

Dublin, Ireland
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, watchinofoye

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

Here is my code:

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:
Code:
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?

« Last Edit: April 30, 2012, 04:59:16 am by ijager » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 486
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://dduino.blogspot.com all my Arduino/electronic projects!!!

{NEW} Getting Started, Learning, Reference + FAQ PDF!!:
[url]http://ar

Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: 1 2 [3] 4 5 6   Go Up
Jump to: