Dangerous Prototypes

Dangerous Prototypes => Bus Pirate Support => Pirate PIC programmer => Topic started by: ammas09 on April 20, 2012, 09:14:13 pm

Title: How do I program a PIC with Bus Pirate?
Post by: ammas09 on April 20, 2012, 09:14:13 pm
Okay first off I am new to programming PIC's and was looking at using the bus Pirate as a PIC programmer.  I have a handfull of questions that I can't seem to find the answer to.

1. can I program newer PIC's without the bus pirate pic programmer board (the extra board that sits on top)

2. Can I write code in C with MPLAB and then compile and send it to my PIC using the bus pirate?

3. If so how do I go about doing this, do I need to download drivers or something like that?

In short I want to write C code, and send it to my PIC chips with the bus pirate.  I just don't know how or even if I can.

Thanks in advance.

(I apologize if this is already addressed, I have been looking for a couple days now and can't seem to find an answer)
Title: Re: How do I program a PIC with Bus Pirate?
Post by: BrentBXR on April 20, 2012, 10:37:57 pm
here is the pic prog's wiki: http://dangerousprototypes.com/docs/Bus ... ng_adapter (http://dangerousprototypes.com/docs/Bus_Pirate_PIC_programming_adapter)

and more information can be found browsing the forums. But as I understand it; at the moment its still (For the most part?) being developed. I do know it has quite a few PICs that are compatible but .

1. X

2. Yes; you can write code in MPLAB; compile it; then upload the hex. Like you would with the Pickit2 standalone application. Once you compile an application; in that projects folder there should be a <project name>.hex file. So really just write it; ensure to properlly link it with its PIC MCU support files and use the correct compiler; and hit the build button. Simple as that to generate a .hex file. I also think there is a 'Export Hex' in the file menu; i could be wrong about that.

3. There is a picProg application package which needs to be used with the Bus Pirate and the pic programmer adapter.
Title: Re: How do I program a PIC with Bus Pirate?
Post by: ammas09 on April 20, 2012, 11:05:57 pm
Thanks I did know of that link.  I was just confused if the adapter was needed or if I could program without it (which it seems I can on several PIC's)  the other part that was confusing me was if you could program directly from MPLAB (or possibly an opensource solution) like you might do with the pickit 2 or 3.

What it seems like, I use MPLAB and generate a hex (from C or whatever language) and then use another program to load this hex into the PIC.  I thought I downloaded the correct program for this from the link above but whenever I launch it is just disappears instantly.

Could I be using the wrong download, I don't know if there is an IDE or something I should be using for this?  Would there happen to be a tutorial that might cover this somewhere?

Thanks for your hello, sorry about being such a noob.
Title: Re: How do I program a PIC with Bus Pirate?
Post by: robots on April 21, 2012, 09:55:16 am
You need to understand that PiratePIcProg does not have GUI. It is command-line only application.

Launch the application from "cmd" and you will see the output.
Title: Re: How do I program a PIC with Bus Pirate?
Post by: tayken on April 21, 2012, 01:06:21 pm
For answer to 1: Currently a few PIC microcontrollers are supported and you can see them here: http://dangerousprototypes.com/docs/Pir ... orted_PICs (http://dangerousprototypes.com/docs/Pirate_PIC_Programmer#Supported_PICs)

Some of them require a high voltage 13V on MCLR pin while programming, those are shown on that table. Basically the rule is: 24F or so is fine without an adapter, but 12F, 16F and 18F ones do need the adapter (there are/may be some extraordinary cases)

The same link I sent you has some usage examples. Wiki is your friend.
Title: Re: How do I program a PIC with Bus Pirate?
Post by: ian on April 23, 2012, 11:23:21 am
Hi ammas09,

The Bus Pirate PIC programmer is a stand-alone application, it does not integrate with the MPLAB IDE. It's a fun hack, but no substitute for a PICkit or ICD.

The app is used from the command line, you tell it where the Bus Pirate is, what chip to program, and what HEX to use. This can also be saved in a .bat file for one-click programming.

Code: [Select]
picprog -p buspirate -u COM12 -s 115200 -c 18F24J50 -t HEX -w OLSv1-bootloader-v1-20MHz.hex -E -V

This is an example of using it from the wiki Tayken linked.
Title: Re: How do I program a PIC with Bus Pirate?
Post by: ammas09 on April 24, 2012, 04:17:46 am
Okay this is making allot more sense now.  Thanks!  I wanted to get into programming PIC's and was thinking about using it instead of a PIC Programmer, but am rethinking that now.

I know this is a little off topic but is this the same case for AVR?
Title: Re: How do I program a PIC with Bus Pirate?
Post by: ian on April 24, 2012, 08:08:51 am
The Bus Pirate fully integrates into the AVR IDE as an STK500 (alternate firmware). It works in Arduino IDE as a native Bus Pirate device with the AVRdude used by the IDE.

If you just need to program a PIC or rescue a project, Bus Pirate is a useful solution. Once you want to get into development then a real programmer is your best bet.
Title: Re: How do I program a PIC with Bus Pirate?
Post by: ammas09 on April 24, 2012, 03:41:58 pm
Thank you all so much for your advice and sharing.  It helps me out allot!