Using PICkit2 with Flowcode

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

User avatar
Steve
Matrix Staff
Posts: 3009
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 72 times
Been thanked: 352 times
Contact:

Using PICkit2 with Flowcode

Postby Steve » Thu Nov 22, 2007 9:18 am

Flowcode can now work seamlessly with Microchip's PICkit2 programming interface with the following instructions:

1) Download the following file:
http://www.matrixmultimedia.com/software/pk2cmd_mtx.zip

2) Extract the contents to somewhere on your PC, for example:
C:\Program Files\PK2CMD_MTX\

3) Run Flowcode and open the compiler options windows

4) Change the "Programmer location" entry to the location of the "pk2cmd_mtx.exe" file you have extracted, e.g.
C:\Program Files\PK2CMD_MTX\pk2cmd_mtx.exe

5) Change the "Programmer parameters" to:
-PPIC%p -F%F.hex -M -A5 -H

6) Make sure "Use programmer to set configuration options" is unticked.

7) Click "OK"

You should now be able to use the PICKIT2 programmer. The PICkit2 device may need to have its firmware updated. If so, instructions can be found in the readme file that was extracted in step (2) above.

Chet
Posts: 60
Joined: Thu Oct 13, 2005 5:05 am
Location: USA
Has thanked: 1 time
Contact:

Postby Chet » Fri Nov 30, 2007 7:14 am

Steve, anything like this for the Picstart plus\Warp 13 programmer?

User avatar
Steve
Matrix Staff
Posts: 3009
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 72 times
Been thanked: 352 times
Contact:

Postby Steve » Fri Nov 30, 2007 10:16 am

Hi Chet,

There's a command-line programmer for these called PICP that may do the job. I've not tried it myself, though.

See here:

http://home.pacbell.net/theposts/picmicro/

Chet
Posts: 60
Joined: Thu Oct 13, 2005 5:05 am
Location: USA
Has thanked: 1 time
Contact:

Postby Chet » Fri Nov 30, 2007 6:49 pm

Thanks Steve, I'm not a crackshot at command line programming
so I hope someone will have a go at it. I guess I just need to
buy the Matrix HP-488 ;)

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 43 times
Contact:

Postby Sean » Thu Dec 06, 2007 6:49 pm

I have been testing the Piklab programmer application (piklab-prog win32 static version) from sourceforge.net. It is currently in beta testing (v0.15.1), has a command line interface that could be made to work with Flowcode, and supports several programmers.

Devices were successfully programmed using ICD2, via COM1 and USB.

Communication with the Picstart Plus seems to fail with a timeout error after reading the firmware revision.

Working ICD2 commands:

piklab-prog -c blank_check -p icd2 -t usb -d 16F877A
piklab-prog -c erase -p icd2 -t usb -d 16F877A
piklab-prog -c run -p icd2 -t usb -d 16F877A

piklab-prog -c program "test.hex" -p icd2 -t usb -d 16F877A
piklab-prog -c verify "test.hex" -p icd2 -t usb -d 16F877A
piklab-prog -c read "testread.hex" -p icd2 -t usb -d 16F877A

usb can be replaced by COM1 when the RS232 connection is used.

The following command caused a Windows error:

piklab-prog -c stop -p icd2 -t usb -d 16F877A

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 43 times
Contact:

Re: Using PICkit2 with Flowcode

Postby Sean » Fri Jan 18, 2008 6:49 pm

It is now possible to use several programming devices directly from Flowcode.

Piklab-prog (available from http://piklab.sourceforge.net/download.php) is a command line interface that is intended to support programmers including Picstart Plus, ICD1 and ICD2. It is still in beta version and we are having some difficulties with Picstart plus, but ICD2 works well using either com1 or usb - we have not tested ICD1.

The downloaded Piklab-prog files should be saved to a suitable folder. I have created a 'Piklab-prog' folder in my existing Flowcode installation.

Piklab-prog seems to require an ICD01xxxx firmware version in the ICD2. An 'upload_firmware' command is available, or this can be done from MPLAB.
Copy the ICD2 firmware file from the \MPLAB IDE\ICD2 installation into the 'Piklab-prog' folder (e.g. ICD01020701.hex).

Create a text file with the following contents and save it to the 'Piklab-prog' folder as 'Piklab-cmd.bat':

"%~dp0\piklab-prog.exe" -c program -p %1 -t %2 -d %3 "%4"

IF "%1"=="icd2" GOTO RunProg

GOTO End

:RunProg
"%~dp0\piklab-prog.exe" -c run -p %1 -t %2 -d %3

:End


Set up the 'Programmer' section of the 'Chip->Compiler Options' menu in Flowcode.

The location path in the following example settings assume a standard installation. It can be adapted to match the selected location of the folder containing piklab-cmd.bat, the Piklab-prog files and the ICD01xxxx.hex file.

Location:
C:\Program Files\Matrix Multimedia\Flowcode V3\piklab-prog\piklab-cmd.bat

Parameters:
icd2 usb %p %D\%f.hex

Note: The 'Browse..." option can not be used to search for piklab-cmd.bat as the filter is set to .exe only.

The icd2 and usb parameters can be changed to match any of the supported programmers.

Examples.

icd2 com1 %p %D\%f.hex (use ICD2 on COM1)

psp com1 %p %D\%f.hex (use Picstart Plus on COM1. * This option is currently causing problems *)

ROMANO1
Posts: 13
Joined: Tue Apr 22, 2008 9:15 am
Contact:

Re: Using PICkit2 with Flowcode

Postby ROMANO1 » Tue Apr 22, 2008 1:57 pm

Hi

What is the version number of Flowcode ?2 or 3?

The config word od PIC if you don't use PPV3 ,how this config word go in the hex file?

Thank

T.ROMANO

User avatar
Steve
Matrix Staff
Posts: 3009
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 72 times
Been thanked: 352 times
Contact:

Re: Using PICkit2 with Flowcode

Postby Steve » Tue Apr 22, 2008 2:11 pm

In the "Chip..Configure" screen, enter the appropriate configuration data like this:

Code: Select all

0x2007,0x3FFC

ROMANO1
Posts: 13
Joined: Tue Apr 22, 2008 9:15 am
Contact:

Re: Using PICkit2 with Flowcode

Postby ROMANO1 » Tue Apr 22, 2008 2:59 pm

Merci but PICKIT 2 don't run the program!!!

I must open PICKKIT and push button "Autoimport hex"

I would like download th Flowcode program in PIC with PICKIT2 without run PIKKIT2 manualy.

Merci

User avatar
Steve
Matrix Staff
Posts: 3009
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 72 times
Been thanked: 352 times
Contact:

Re: Using PICkit2 with Flowcode

Postby Steve » Tue Apr 22, 2008 3:08 pm

The instructions to do this are at the top of this topic - i.e. the "pickit2cmd_mtx" program.

You should not need to launch PICkit2 manually. In fact, you should be using a command-line version of this programmer, and not the GUI application that comes with the PICkit2 device.

Is this not working for you? Please tell me what error messages you are receiving.

ROMANO1
Posts: 13
Joined: Tue Apr 22, 2008 9:15 am
Contact:

Re: Using PICkit2 with Flowcode

Postby ROMANO1 » Tue Apr 22, 2008 3:26 pm

Sorry but I have no really error message!!!I have strange char on line.If you want i can mail a screen capture!

C:\PICKIT\pk2cmd_mtx.exe -PPIC16F877 -FTestPIC.hex -M - E -A5 -R


.......

\ \ \ \|/-\|/-\|/-\|/ \ PICkit 2 Program Report
22-Apr-2008, 15:30:08
Device Type: PIC16F877




Under Flowcode

Programmer location:c:\PICKIT2\pk2cmd_mtx.exe
Parametres -PPIC%p -F%f.hex -M -A5 -R

I have add -R for reset my card but don't run the program on my PIC card
I have had -E for erase before same result

The only case ok ,if I run manualy PICKIT and AUTOWRITE......!!!!!

1/2 Day of work for nothing!!!

If you can I have Messenger with cam .

User avatar
Steve
Matrix Staff
Posts: 3009
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 72 times
Been thanked: 352 times
Contact:

Re: Using PICkit2 with Flowcode

Postby Steve » Tue Apr 22, 2008 3:31 pm

The exact parameter line that works here is this:

Code: Select all

-PPIC%p -F%F.hex -M -A5 -H


The "-H" holds the 5V onto the target after programming. And the "%F" must be capitalised.

Also, you may need to reflash the firmware of the PICkit device (instructions are in the text file).

ROMANO1
Posts: 13
Joined: Tue Apr 22, 2008 9:15 am
Contact:

Re: Using PICkit2 with Flowcode

Postby ROMANO1 » Tue Apr 22, 2008 3:55 pm

MERCI BEAUCOUP!!!

but for info the %f capitalised or not is not "important"

IT's the -H but I send you a peace of help and I don't see why -H power?

************************************
(Serial EEPROM memory is 'P')
H<value> Delay before Exit Exit immediately
K = Wait on keypress before exit
1 to 9 = Wait <value> seconds
before exit
*****************************************

User avatar
Steve
Matrix Staff
Posts: 3009
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 72 times
Been thanked: 352 times
Contact:

Re: Using PICkit2 with Flowcode

Postby Steve » Tue Apr 22, 2008 4:00 pm

Great - I'm glad it now works. The reason for "H" was "Hold power".

I do not know where your help text has come from. It is not from the version of the command-line PICkit2 programmer that I modified to create the version in the download above.

echase
Posts: 426
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times
Contact:

Re: Using PICkit2 with Flowcode

Postby echase » Sat May 10, 2008 3:53 pm

I have upgraded Flowcode, the command line interpreter and the firmware.

I assume putting that firmware file in the right location actually does lead to a firmware upgrade. Not clear how it 'transfers' that file to the hardware.

I don’t want the programmer to power the circuit with 5V after programming as my circuit works off 3V. Can I just remove the –H parameter? Or reset the voltage to 3V? But if find the PIC won’t programme at 3V


Should config parameters still be as per the default?

-cs 2 -chip PIC%p –config

Your link above http://www.matrixmultimedia.com/software/pk2cmd_mtx.zip is confusing as it appear to lead to an older version of the batch files. Is there not a later 2008 version?

Whichever version I use I get the error message as below despite the PK2DeviceFile definitely being in the location stated. So how do I get it to work?

Error message in Flowcode:-

Launching the programmer...

C:\Program Files\Microchip\PICkit 2 v2\PK2CMD_MTX\pk2cmd.exe -PPIC16F886 -F886v13.hex -M -A5 -H

PK2DeviceFile.dat device file not found.
........
Return code = 24

Flowcode was unable to transfer the flowchart to the microcontroller. Check the programmer options and physical connections.

FINISHED

echase
Posts: 426
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times
Contact:

Re: Using PICkit2 with Flowcode

Postby echase » Wed May 14, 2008 11:34 pm

Still can't solve it. What do I do?

User avatar
Steve
Matrix Staff
Posts: 3009
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 72 times
Been thanked: 352 times
Contact:

Re: Using PICkit2 with Flowcode

Postby Steve » Thu May 15, 2008 9:05 am

The latest release of Flowcode contains identical files to those in the zip file - I've just checked.

But I have noticed the problem you are having. You are using the "pk2cmd.exe" file which is Microchip's version. I had to edit the source of this file and recreate it to get around a few problems with their original program. You should use the "pk2cmd_mtx.exe" file instead (one of the problems with their original file is that it did not look in the obvious place for the "dat" file - i.e. the same directory as the exe!).

The "config" parameters are not required at all - you should make sure the "Use programmer to set configuration options" is unticked.

For the voltage, change the "-A5" parameter to "-A3.3". You should keep the "-H".

I hope this helps. And sorry for the delay in responding - I let this one slip through the net.

Novus
Posts: 3
Joined: Wed Jun 04, 2008 8:30 pm
Been thanked: 1 time
Contact:

Re: Using PICkit2 with Flowcode

Postby Novus » Thu Jun 05, 2008 9:23 am

Hi All

Please let me say that I am a total beginner to the whole PIC programming thing. I bought Flowcode V3 and have updated it this week. I also have the PICKit2, which I also updated.
I have been trying to program my PIC in the way you are describing, but when I plug it into the circuit, nothing happens.
So, here is what I do: I create the flowchart for what I want the IC to do. I run the simulation and it works great. (Obviously I save the file). After that I compile the chart to the IC. PICKit2 powers up and gives the busy sign, and then the status window shows succesful.
Am I missing something? I reaaallyy want this to work, but am lost.

Please help?

User avatar
Benj
Matrix Staff
Posts: 13173
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 3824 times
Been thanked: 3665 times
Contact:

Re: Using PICkit2 with Flowcode

Postby Benj » Thu Jun 05, 2008 9:29 am

Hello

It sounds like your microcontroller is being programmed correctly.

In the Chip -> Configuration menu of Flowcode make sure you have configured your microcontroller correctly. Eg if you are using a crystal to clock your microcontroller then you will need to use the XTAL setting, Also make sure that the watchdog setting is turned off. You should also check that the clock speed setting in the Chip -> Clock speed menu matches your crystal frequency.

The easiest way to check that it is all working is to create a while 1 loop and inside the loop create a program to light an LED wait a second and then switch off the led and wait another second. This will also confirm if you have all your clock speeds configured correctly on the hardware and inside Flowcode.

Novus
Posts: 3
Joined: Wed Jun 04, 2008 8:30 pm
Been thanked: 1 time
Contact:

Re: Using PICkit2 with Flowcode

Postby Novus » Thu Jun 05, 2008 10:29 am

Hey Benj

Unfortunately the Chip - Configuration Menu is non-exist to my knowledge on V3 of Flowcode. I only have a window that tells me I can "enter" config details manually. ( :oops: Am I allowed to ask what config details I have to enter here for the 12 and 16 series PICs?)

User avatar
Steve
Matrix Staff
Posts: 3009
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 72 times
Been thanked: 352 times
Contact:

Re: Using PICkit2 with Flowcode

Postby Steve » Thu Jun 05, 2008 10:46 am

Hello,

The configuration bits you need to set largely depend on your hardware setup. Please consult the datasheet for the device you are using and pay particular attention to the clock configuration settings (and also turn the WDT off if you are not using it).

The format to enter this config info is explained in and around this post:

http://www.matrixmultimedia.com/mmforums/viewtopic.php?f=5&t=2431&p=5190&hilit=0x2007#p5190

I hope this helps.

Novus
Posts: 3
Joined: Wed Jun 04, 2008 8:30 pm
Been thanked: 1 time
Contact:

Re: Using PICkit2 with Flowcode

Postby Novus » Thu Jun 05, 2008 11:12 am

Thank you, I will investigate and explore these options as soon as I get a chance!
Will provide feedback... :)

mimiyum
Posts: 94
Joined: Wed Jul 16, 2008 4:39 pm
Location: Philippines
Been thanked: 1 time
Contact:

Re: Using PICkit2 with Flowcode

Postby mimiyum » Tue Aug 05, 2008 12:55 pm

hello! before i try to change the programmer option on my flowcode to be able to use my PICKit2 programmer, i would like to ask a few questions:

1. is this reversible coz i still want to program my buggy directly from flowcode
2. will any of this work with the demo version. (My full version is taking ages to arrive! :cry: )

thanks! :lol:

mick the mend
Posts: 2
Joined: Tue Jul 22, 2008 8:24 am
Contact:

Re: Using PICkit2 with Flowcode

Postby mick the mend » Tue Aug 05, 2008 3:06 pm

Hi can someone help?
I am using a 16f628 for a simple project but cannot get the IC to do anything in circuit.
I have followed Steves instructions about using a Pickit 2 to the letter regarding the setting up of the programmer, the only question I have about the config word is the format. I am using the internal osc with clock out.
When in circuit I have no activity but I have odd DC voltages on the clock pins. 1V on clkout and 2.5V on clkin (these only appear when internal clock config is selected), any other settings just 0v on all pins apart from 5V power.
I have included all the files generated for anyone who can help.
I am getting desperate and am close to throwing the thing away and using logic gates instead.

Thanks all

Mike
Attachments
HEART.rar
(97.63 KiB) Downloaded 1091 times

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 43 times
Contact:

Re: Using PICkit2 with Flowcode

Postby Sean » Tue Aug 05, 2008 4:37 pm

The problem might be with the /MCLR signal. It is currently configured to be externally driven via RA5, and will require a pull-up resistor (10k) to the 5v supply to prevent the chip from remaining in the reset state.

Alternatively, the configuration settings can be changed by setting the 'Master Clear Enable' option to 'Disabled'. This will connect the /MCLR signal to the 5v supply internally, and allow RA5 to be used as a normal I/O pin.

Care should be taken with any external devices connected to this pin because of the high voltge (Vpp) that is applied during normal high voltage programming.