PDA

View Full Version : Connecting programmer to MicroCode Studio



KrashKaloop
- 6th September 2008, 16:48
New to this forum, and new to PIC programming as well.

I have just started to learn about PIC programming. I started by downloading MPLAB and doing some of the tutorials. Then I purchased this programmer http://www.futurlec.com/PIC_Programmer.shtml , built a development board to blink LED’s and started having some success.

But developing in ASM is not my cup of tea, so I have downloaded the demo version of PICBasic Pro and I am trying to use it.

The problem is I cant’t seem to figure out how to connect the programmer to MicroCode Studio. I know I can just use the files generated by PBP to use in MPLAB to program the PIC, but I want to program directly from MCS.

The programmer says it is Pickit2 compatible if that helps.

Any help would be appreciated, but it needs to be tailored to a complete novice.

skimask
- 6th September 2008, 17:30
In MCS, select menus -> "View" -> "Compile and Program Options..."
Point MCS to the PBP directory (or let it find it automatically) under the Compiler tab
Point MCS to the MPLAB directory (or let it find it automatically) under the Assembler tab
Point MCS to the PICKIT2 by creating a custom programmer entry and point MCS to the PICKIT2 executable.
Press F9 in the main MCS window to compile the source code, assemble the source code, and start the PICKIT2 programmer.
Not sure if it works with the PICKIT2 clones though.
My advice... Spend the $50 and buy the real PICKIT2...

b1arrk5
- 6th September 2008, 17:35
I'll try. Under the MicroCode Studio menu select View, then select Compile and Program Options..., then click the Programmer tab, and press the Add New Programmer... button. Then select the Create a Custom Programmer Entry radio button and press Next. Enter the name you want to call your programmer, it can be anything you want, and press Next. Then enter the name of the executable file that you use to run the programmer, it will be something.exe, and press next, then either select the find automatically for find manually buttons, and press next. When your finished, just go back to the View menu and make sure that your new programmer is set as the default in the little window, and you should be good to go.

Any more problems, just let us know, there are a lot of pretty smart folks around here who'll do their best to get you going.

Welcome to the forum!
Jerry

Archangel
- 6th September 2008, 20:17
Not sure if it works with the PICKIT2 clones though.
My advice... Spend the $50 and buy the real PICKIT2...

The clones on eBay run $34.99, the real PICKIT2 programmer by itself from Microchip is presently $34.99 The kit with a Developers board is $49.99.
http://www.microchipdirect.com/productsearch.aspx?Keywords=DV164120
http://www.microchipdirect.com/productsearch.aspx?Keywords=PG164120

KrashKaloop
- 6th September 2008, 22:02
Thanks. I got it.... now where can I find a good basic tutorial for PICBasic?? I only have PIC16F876A, but I can buy some different PIC's if they are necessary.

Thanks for the help.

mackrackit
- 6th September 2008, 22:22
Welcome,

Sample programs can be found here
http://www.melabs.com/
and here
http://rentron.com/
Bruce is working on a book also.

The manual has the basics and read this forum for the trickier stuff.

This is also a good place to go
http://www.picbasic.co.uk/forum/forumdisplay.php?f=16
At the bottom of the page select "From the Beginning" to see all of the threads.

KrashKaloop
- 7th September 2008, 01:59
OK, I thought I had it, but I don’t. Although my programmer is working, the files created in MCS are not being loaded into the PICkit 2 program.

When "compile and program" is selected in MCS, the file is compiled with no errors and the PICkit 2 programmer window opens. Then my programmer lights up and the PICkit 2 programmer shows a successful program loaded into the PIC. Unfortunately, all that is loaded is blanks (all “3FFF”).

Somehow the HEX file is not being loaded into the PICkit 2 software.

I don’t know if I am explaining this well, but can anyone help? Could this be that I left the last step out during the programmer setup? It was a blank box that had somthing to do with linking the HEX code. I didn't know what to enter there.

Pic_User
- 7th September 2008, 15:11
OK, I thought I had it, but I don’t. Although my programmer is working, the files created in MCS are not being loaded into the PICkit 2 program.

When "compile and program" is selected in MCS, the file is compiled with no errors and the PICkit 2 programmer window opens. Then my programmer lights up and the PICkit 2 programmer shows a successful program loaded into the PIC. Unfortunately, all that is loaded is blanks (all “3FFF”).

Somehow the HEX file is not being loaded into the PICkit 2 software.

I don’t know if I am explaining this well, but can anyone help? Could this be that I left the last step out during the programmer setup? It was a blank box that had somthing to do with linking the HEX code. I didn't know what to enter there.Hi KrashKaloop,

Welcome to the forum.

Just went through the same problem. The PICkit2 is new to me too.

I found that the top box, of the three boxes, in the lower right-hand corner, of the single screen, PICkit2 programming window, labeled [“Auto Input Hex + Write Device”] worked.

But, you have to know (remember) where MCS put the hex file and what it is called. :)

You know you have the hex file loaded (ready to progam) when it shows up in the PICkit2 [Source:] window.

-Adam-

KrashKaloop
- 7th September 2008, 16:40
Thanks Pic User,

Yes, I knew that the upper button would import and write the file to the PIC and you can also use the file menu to open a HEX file and then program the PIC. But I thought there was a way to compile and load the current file from MCS into PICkit2. I guess if I have to load the file manually each time, I certainly can, but I thought there was a one click procedure available to get the file over to the PICkit2.

mackrackit
- 7th September 2008, 17:42
You are some how using the PICKIT2 software with the clone you have?

When you get a real PICKIT there is no reason to mess with MCS like you are trying, Just follow Adam's instructions. Works great.

tcbcats
- 1st January 2009, 02:27
I just installed a new PICkit2 and would like to know if the auto start and program will work.
When I select compile and program in the IDE, the programmer app starts but I have to manually grab the hex file and do the load from the PICkit2 application (2 steps).
Some other programmers will accept a script file in the IDE that will allow them to compile and program your PIC with one click...
Does anybody know the correct script to make the PICkit2 program the PIC when started by the IDE?
Thanks,
....Microcode studio plus 3.0.0.5
....18F252

rmteo
- 1st January 2009, 02:40
With the PicKIT2, you don't need a script for one-step programming - use the circled feature (works with any compiler/IDE):

http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3086&stc=1&d=1230777570

tcbcats
- 1st January 2009, 03:01
Yes I use it that way now.
I would like to use the programmer as I use the MEL USB unit and make it a one click use.
Once you go one click.... you don't want to go back...
Do you know if the PICkit2 can even be driven to do "one click" form the IDE like the MEL programmers?

mackrackit
- 1st January 2009, 03:08
Use the suggestion rmteo gave.

Whenever the hex is changed, PICKIT2 software will see it, reload it, and then program the PIC. You have to do nothing.

Darrel Taylor
- 1st January 2009, 03:21
What you need is the "PICKit2 Command Line Interface".

http://ww1.microchip.com/downloads/en/DeviceDoc/PK2CMDv1-12.zip

1 click from Microcode Studio (compile and program).

tcbcats
- 1st January 2009, 03:26
Maybe I did not ask my question in the correct way...
The IDE has a button that will compile and program(flash) your PIC with one click (if you have the correct script installed). It starts the programmer application if it is not running and then the programmer programs the PIC... you do not have to touch anything in the programmer GUI... it basically runs in parallel with the microcode IDE.... I mean ONE click to do everything. It is very fast and it is a part of the Microcode studio IDE to programmer interface.
The MEL programmers all can read a script and be automated.... I do not know if the PICkit2 has this feature where it can be totally remote controlled from the IDE.
Perhaps I should ask this on the Microchip forum??
**************

mackrackit
- 1st January 2009, 03:27
What you need is the "PICKit2 Command Line Interface".

http://ww1.microchip.com/downloads/en/DeviceDoc/PK2CMDv1-12.zip

1 click from Microcode Studio (compile and program).

???
The Auto Import Hex from the PICKIT2 software already does this once the hex is selected.

tcbcats
- 1st January 2009, 03:28
Thanks Darrel,
I will check it out...
tcbcats

Darrel Taylor
- 1st January 2009, 06:48
???
The Auto Import Hex from the PICKIT2 software already does this once the hex is selected.
I've never tried it that way.
Perhaps it works fine ...

But I know the Command Line Interface gives one click from MicroCode Studio to PIC.
It's what I use for the PICkit2. I also have an EPIC, and a meLabs U2.

It's been awhile since the installation, I don't remember if it was automatic or if I had to figure it out.
But these are the parameters for the PICkit2 programmer.
-pPIC$target-device$ -f$hex-filename$ -M -R -T -h2

1Hr left this year :)
Well, In my time zone.

Happy new year!
Kiss someone next to you. :p

mackrackit
- 1st January 2009, 06:59
I've never tried it that way.
Perhaps it works fine ...

But I know the Command Line Interface gives one click from MicroCode Studio to PIC.
It's what I use for the PICkit2. I also have an EPIC, and a meLabs U2.

It's been awhile since the installation, I don't remember if it was automatic or if I had to figure it out.
But these are the parameters for the PICkit2 programmer.
-pPIC$target-device$ -f$hex-filename$ -M -R -T -h2
When I use windows I just use the PICKIT2 soft ware.
On Linux I use this
http://www.cannasoftware.com/content/view/32/1
Both work well.



1Hr left this year :)
Well, In my time zone.

Happy new year!
Kiss someone next to you. :p
I am in the shop by myself, a real party animal :D
HAPPY NEW YEAR!!!

tcbcats
- 1st January 2009, 08:27
Darrel...
Did this give you the one click flash function from the IDE?
-pPIC$target-device$ -f$hex-filename$ -M -R -T -h2

I tried this and several variants with no luck.
The programmer application starts... no problem... but does not do it's thing without clicking the auto import button.

Darrel Taylor
- 1st January 2009, 09:28
Happy new year!
Kiss someone next to you. :p

I am in the shop by myself, a real party animal :D
HAPPY NEW YEAR!!!
Then kiss your DrillPress.
I would if I had one ... :rolleyes:
But, right now, the mop looks pretty good too.

tcbcats: Thru my blurry eyes tomorrow, I will attempt to verify the process.
It works, It's sweet.

Hflppy Neflear!

Darrel Taylor
- 1st January 2009, 21:08
Download the latest PICkit2 GUI, and the "PICKit2 Command Line Interface" from Microchip.
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en023805

Extract all files from PK2CMD to your "C:\Program Files\Microchip\PICkit 2 v2" folder.
It's the same folder as the PICkit2 programmer software.

In Microcode Studio View | Compile and Program Options... | programmer tab,
click Add New Programmer, select "Create a custom programmer entry" then click "Next".
Enter any name you wish to call it and click "Next".
Enter pk2cmd.exe as the "Programmer Filename" and click "Next".
Click the "Find Manually" button and point it to C:\Program Files\Microchip\PICkit 2 v2 and click "Next".
Enter this parameter line

-pPIC$target-device$ -f$hex-filename$ -M -R -T -h2

Then click Finished.

Pressing Compile and Program or F10 in MicroCode Studio will now do it all.

<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3146" /><!-- 3146 -->

Descriptions of those, and additional command-line parameters can be found in the "Readme For PK2CMD.txt" file from the .zip above.
<br>

tcbcats
- 3rd January 2009, 07:19
Darrel,
I set up my programmer as you directed and still get the same results...
The PICkit2 application starts and and just shows that it found the connected PIC... thats all. I have to manually click the putton and then select the hex to get it to program the target PIC.
Just before the application starts the programmer shows activity but that is maybe just reading the target PIC to confirm a connection.
I tried many of the other commands in the readme file with no luck.
It looks like the command never actually runs or has some other error.
The PICkit2 application gets started from the programmer path you enter in the IDE so its the script that is not working.
My new USB U2 came today and it works with the script... so I guess I will scrap the PICkit... too bad the price is right and it does work if manually directed. It also works as stand alone.
Maybe MEL has some other info on how to get the PICkit2 to work with the script.:(

Darrel Taylor
- 3rd January 2009, 07:32
Are you sure you entered pk2cmd.exe as the Programmer Filename.
It opens a DOS window, not the PICkit2 GUI program.

If it's opening the GUI, something's definitely not right.
<br>

iw2fvo
- 3rd January 2009, 14:56
Hi to you all !
I do have to launch the MPLAB in order to programm the PIC directly from the MCS. At the moment I use the MCS and MPASM and then i call the MPLAB to program the chip. I will like to do it in a single action.
Thanks for any suggestion .
Regards,
Ambrogio
IW2FVO
North Italy

rmteo
- 3rd January 2009, 16:04
See posts #8,12,14,17.

tcbcats
- 3rd January 2009, 21:23
Darrel,
I changed the programmer exe and now I get a dos window for a short instant... then it goes away... It is so fast that I cnnot see anything in the window.... programmer does nothing and target PIC is not read or programmed.
So...the dos is starting but not reading any script.

Are you actually using the script and one click programming from the IDE?
I have configured my IDE to place my compiled code in the PICkit2 folder.

Darrel Taylor
- 4th January 2009, 00:30
The -h2 parameter causes it to pause for 2 seconds before closing the window.
But since you didn't do the "Programmer Filename" step, I assume you didn't do the parameters either.

What I showed above was a series of steps that must be completed for it to work. ALL steps must be completed exactly as shown. Miss one, it won't work.


I have configured my IDE to place my compiled code in the PICkit2 folder.Not sure how you did that. As far as I know, that's not an option in Microcode Studio.
You can set the default folder that comes up for a File|Save, but if you're saving everything in your PICkit2 folder, that's just plain silly.

tcbcats
- 4th January 2009, 01:42
I just set the IDE default file to the PICkit2 folder for my testing.... with a LED light blinker test program.
The -h2 does nothing I tried -h5 ....+ all combos etc with no change in the way the dos window flashes by.
I can only conclude that the script is not being read, is in the wrong place, or not constructed correctly.Is there something in the PICkit2 ini file that needs to be changed if you use the dos script vs the programer GUI?

It would help if I could get an actual screen copy of the working script from a working machine.

I assume that you are not actually using the PICkit2 with one click commands from the Microcode studio plus GUI.(that is the compile and program button)

The steps outlined in your post and confirmed in the IDE and programmer help files do not work on my system.

The example script files in the programmer help files are not in the same format as your example but I tried the examples and got the same results.

I was able to see that the dos popup displays an "\" and then quits in 1/2 second. There is no other text shown on the DOS screen... I assume I should see the script run and some delay before the dos screen closes.

Darrel Taylor
- 4th January 2009, 03:03
I'm sorry that you were unable to make it work.

Other than taking a video of me actually compiling a program and downloading with 1-click, I don't know how to convince you that it does work.

It's totally possible I've missed a step, but after deleting everything and going through the process from scratch, I see nothing that would help.

Best bet ... Use the instructions from posts #8,12,14,17.
<br>

tcbcats
- 4th January 2009, 03:40
Darrel,
I got it to work....
I had to remove the PICkit2 programmer from the IDE list of programmers and then re make the custom programmer again from scratch.
It seems that you cannot edit both the path and script without dumping the old setings.
It was an IDE problem.... If you have to edit the extsting path or programmer .exe, then you must dump the old programmer entry totally and start over.
Thanks for the help.....:D

Darrel Taylor
- 4th January 2009, 04:30
EXCELLENT!

That must be the Step I was missing.

Thanks tcbcats.

chas11
- 15th July 2014, 22:22
I have a PICkit2 clone and DT explanation works if followed to the letter, the only thing I changed was the cmd line to one suggested in another post: -PPIC$target-device$ -F$hex-filename$ -E -M -Y -Y -h9, then the dos cmd box will open with erasing device followed by three msg's and waiting 9 sec before closing allowing user time to view error's if any.

Note:if dos cmd box closes quickly then you have made a mistake during installation or the choosen device in Microcode Studio
selection box is incorrect(example 16F877A when should be 16F877)