PICKIT2 users

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

Moderators: Benj, Mods

Post Reply
User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

PICKIT2 users

Post by Steve »

EDIT: please note that the information in this post has been superceded by the info in this post:
http://www.matrixmultimedia.com/mmforum ... f=5&t=4161

If any of you use Microchip's PICKIT2 as a programmer, then here's how to get it working with Flowcode:

1) create a batch file called "PICKIT2.BAT" and put the following into it:

Code: Select all

copy "%1\%2" "C:\temp\PICKIT.HEX"
(it is up to you where and what you call the "PICKIT.HEX" file).

2) Run Flowcode and change the "programmer" entry in the "Compiler options" screen to the location of this BAT file.

3) Put the parameters as "%D %F.hex" (without the quotes), and uncheck the "use programmer to set config" option.

4) The PICKIT2 software has a special "Auto import HEX and write file" button - run PICKIT2, click this button and select the "C:\temp\PICKIT.HEX" file (you may need to run Flowcode once first to create this file). Then leave the PICKIT2 software open.

Now each time you compile a program, the generated HEX file will be copied to "C:\temp\PICKIT.HEX". Each time this file is recreated, PICKIT2 will detect the change and automatically download the HEX file.

It does not matter what name you give your Flowcode program, because the HEX will will be automatically renamed at the programming stage.

Note that you will need to run step 4 each time you restart your PC, but the other settings should be retained.

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times

FlowCode I MPLAB ICD2 Programmer

Post by Ron »

Hi,

Do you have this information for an MPLAB ICD2 USB programmer? I am a beginner and bought the ICD2 programmer.

I have only posted a few times and you and others have responded quickly, keep up the good work.... Now to vent.

I ordered my FlowCode Pro back on April 17, 2007, the distributor left a message today, May 14, 2007, that they will have it in on or about May 22, 2007. Then another week to get it to me, now my project is 4+ weeks behind schedule.

From the looks of things support is great, to bad Electronix Express tells your future customers they have the item in stock, then not call you to tell that they need to order it and tell you it will take 1 - 2 weeks to get, I called then to check on the status of my order. Then they never bothered to call me 3 weeks later to tell me it will actually take 5 -6 weeks with more excuses.

If it was not for one of your supporters on this forum, James Humphries, I would have canceled my order and used a competitors flowchart software.

It is sad to think how many customers you have lost because of such poor support by the people you trust to represent your company and products.

Venting done.....

Keep up the great job of supporting your products.

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

Hello Ron,

With the ICD2 programmer, i's a little more tricky. As faras I know, the ICD2 can only program devices via the MPLAB IDE. As yet, Flowcode cannot be run from inside this IDE, but I am looking into it.

There is a way around it. Flowcode produces a 'C' code file which is used to create a HEX file by the C compiler/linker. This compiler/linker also produces an ASM file. You can take this ASM file and use it as the basic for an MPLAB project (assembling it with MPASM, and then programming it with the ICD2).

If you additionally bought an appropriate licence for the BoostC compiler, you could take the C code file and recompile this within MPLAB in the same way.

As for the problem with receiving the CD, I will contact you directly with a temporary solution that should get you up and running immediately.

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

Post by echase »

My first test programme to turn on one LED on PICKIT's supplied low pin count demo PCB with its16F690 worked OK. But the next test which turns on LED0 for 1 sec, then off for 1 sec, then LED1 the same, then 2, then 3, repeated failed completely. It either turns on LED0 solidly if I set the clock speed low or LED0, 1 and 2 on solidly if clock speed is set higher. No flashing. What might I have got wrong as the behaviour of the programme in Flowcode and the actual chip is completely different?

One problem is that you loose the Flowcode (PPP) Chip Configure screen with this batch file. So how can one set things like clock type (XT, RC, etc) as there is no such screen in PICKIT 2 Programmer software? All you get to choose there is the chip type. This PCB runs with an RC clock and maybe Flowcode has set it to XT somewhere.

What would happen if you did not use the batch file but instead just took the normally generated HEX file and input it into the PICKIT 2 Programmer? Does it have the right header info or whatever it needs?

Just a word of caution. Make sure you type Steve’s instructions exactly e.g. PICKIT2.BAT has a 2 in it but PICKIT.HEX does not. Also need to use ‘compile to chip menu’ and not ‘compile to HEX’ as I initially tried

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

Post by echase »

Here is the ASM of the above 4 LED programme. What clock type has it set? I can't read ASM.

I have truncated the listing to save space.

;// Code Generator: BoostC Compiler - http://www.sourceboost.com
;// Version : 6.70
;// License Type : Standard License
;// Limitations : PIC12,PIC16 max code size:4096 words, max RAM banks:Unlimited, Non commercial use only
;/////////////////////////////////////////////////////////////////////////////////

include "P16F690.inc"
; Heap block 0, size:96 (0x000000A0 - 0x000000FF)
__HEAP_BLOCK0_BANK EQU 0x00000001
__HEAP_BLOCK0_START_OFFSET EQU 0x00000020
__HEAP_BLOCK0_END_OFFSET EQU 0x0000007F
; Heap block 1, size:80 (0x00000120 - 0x0000016F)
__HEAP_BLOCK1_BANK EQU 0x00000002
__HEAP_BLOCK1_START_OFFSET EQU 0x00000020
__HEAP_BLOCK1_END_OFFSET EQU 0x0000006F
; Heap block 2, size:76 (0x00000024 - 0x0000006F)
__HEAP_BLOCK2_BANK EQU 0x00000000
__HEAP_BLOCK2_START_OFFSET EQU 0x00000024
__HEAP_BLOCK2_END_OFFSET EQU 0x0000006F
; Heap block 3, size:0 (0x00000000 - 0x00000000)
__HEAP_BLOCK3_BANK EQU 0x00000000
__HEAP_BLOCK3_START_OFFSET EQU 0x00000000
__HEAP_BLOCK3_END_OFFSET EQU 0x00000000
Last edited by echase on Mon Jul 16, 2007 1:55 pm, edited 2 times in total.

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

Post by Benj »

Hello

Sounds like in the slow mode it is running too slow to allow the flashing to work.

This is then turned on its head in the fast mode when te program is running so fast that it appears that all the LEDs are on.

Try inserting some delays in between the switch on and off statements.

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

Post by echase »

Thanks but does not answer all the questions.

1) Where can I sent parameters like Clock Type, Watchdog Timer, Power Up Timer, Low Volt Programme etc on/off as there is no longer any Chip Configure screen , especially the Expert Config screen?

2) The documentation with the low pin count demo PCB is vague about (or I can’t find it) what the RC clock speed is, but there is a variable resistor to adjust it over >10:1 range. In the above cases I tried various steps in the 10Khz to 10Mhz range and all positions of the resistor so I don’t think Ben’s explanation makes sense as I would have set the right speed somewhere in the testing. I think it more likely I have set it to XT when its using a RC clock and/or one of the Expert Config parameters is wrongly set (and I can't access these settings now, see 1)).

3) In PPP the 16F690 chip is not listed so even if I don’t use the batch file process I can’t set the PIC clock to RC mode.


4) Please could you paste here the correct settings to undo Steve’s instructions “2) Run Flowcode and change the "programmer" entry in the "Compiler options" screen to the location of this BAT file. 3) Put the parameters as "%D %F.hex" (without the quotes), and uncheck the "use programmer to set config" option.” Otherwise I have to reinstall Flowcode to get them back.

5) What would happen if I did not use the batch file but instead just took the normally generated HEX file from Flowcode and input it into the PICKIT 2 Programmer? Does it have the right header info or whatever it needs?

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

echase wrote: 1) Where can I sent parameters like Clock Type, Watchdog Timer, Power Up Timer, Low Volt Programme etc on/off as there is no longer any Chip Configure screen , especially the Expert Config screen?
You could run PPP separately and select "configure". You will need to be in expert mode - untick the "use simple config screen" box in the "options" screen. You should then manually select the chip and then select the appropriate configuration settings.

Now, the lower-right side of the config screen will display the appropriate configuration value - e.g. 0x30F4. Take this value, and put it into the "configure" window in Flowcode like this:

Code: Select all

0x2007,0x30F4
(You will need to make sure the "use programmer to set configuration options" box in the "config settings" window is unchecked).
echase wrote: 2) The documentation with the low pin count demo PCB is vague about (or I can’t find it) what the RC clock speed is, but there is a variable resistor to adjust it over >10:1 range. In the above cases I tried various steps in the 10Khz to 10Mhz range and all positions of the resistor so I don’t think Ben’s explanation makes sense as I would have set the right speed somewhere in the testing. I think it more likely I have set it to XT when its using a RC clock and/or one of the Expert Config parameters is wrongly set (and I can access these setting now, see 1)).
The low pincount demo board does not have an external oscillator circuit, so you need to use its internal oscillator setting. The first example in the datasheet has this configuration:

Code: Select all

__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF &
_MCLRE_OFF & _CP_OFF & _BOD_OFF & _IESO_OFF & _FCMEN_OFF)
The internal oscillator of the 16F690 defaults to 4MHz, but can be changed via the OSCCON register.
echase wrote: 3) In PPP the 16F690 chip is not listed so even if I don’t use the batch file process I can’t set the PIC clock to RC mode.
You need to use the "expert" config screen - see above.
echase wrote: 4) Please could you paste here the correct settings to undo Steve’s instructions “2) Run Flowcode and change the "programmer" entry in the "Compiler options" screen to the location of this BAT file. 3) Put the parameters as "%D %F.hex" (without the quotes), and uncheck the "use programmer to set config" option.” Otherwise I have to reinstall Flowcode to get them back.
Clicking the "restore defaults" button should return the programmer setting. If not, here's what I have:

Code: Select all

Programmer: C:\Program Files\Matrix Multimedia\PPPv3\PPPv3.exe
Parameters: -cs 2 -chip PIC%p -nogui "%f.hex"

"Use programmer to set configuration options" is ticked
Config parameters: -cs 2 -chip PIC%p -config

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

Post by echase »

Looks promising although can't try it out now. Some more questions

1) What is the '0x2007' in '0x2007,0x30F4'? Is it always set to '0x2007?' Or PPP sometimes gives Config I and Config 2 words. Is the '0x2007,0x30F4' these two words?

2) My PPP v3.8.11.24 goes straight from 16F688 to 16F716 so there is no 690, even on the Expert screen, despite your reply. Where has it disappeared to? Have I an obsolete version?

3) What exact clock type/speed should I set? Internal RC No Clock, XT or EC, etc? (I was mistaken, the variable resistor is used in some Microchip sample programmes to vary the program speed but it's via AN0 analogue input rather than by clock speed change.)

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

0x2007 is the location of the configuration word in the PICmicro memory map.

Most 16F devices have only one config word at this location. Those with 2 words (e.g. 16F88) use locations 0x2007 and 0x2008.

The 18F series of chips have 14 config words and the "config" box within Flowcode should look something like this:

Code: Select all

0x300000,0x3f
0x300001,0xce
0x300002,0x3f
0x300003,0x1f
0x300005,0x86
0x300006,0xed
0x300008,0x3
0x300009,0x40
0x30000a,0x3
0x30000b,0x60
0x30000c,0x3
0x30000d,0x40
There is a new version of PPP - v3.9 - which has the 690 and others.

Use "Internal RC No Clock" - this will allow you to use both OSC pins as I/O lines.

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

Post by echase »

Hurray, by following Steve’s instructions I made it work, thanks. This is my very first self written code that I have run on a PIC.

But I did find I had to repeat step 2 as well as 4 upon restart, probably because I had upgraded PPP. Suggest you read all of Steve's input here as you have to do a little more than just contained in his first post here, especially to set the config word(s).

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

Post by echase »

Also beware that batch file won't work with long filenames for main Flowcode file. Presumably it works with DOS conventions on filenames rather than Windows ones

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

Post by echase »

In the 886 datasheet it implies that both its 2 config words are at 0x2007. not 0x2007 and 0x2008. Or is '0x2007' in Microchip speak shorthand for '0x2007 and subsequent locations'?

I had used

0x2007, config word 1
0x2008, config word 2

But should it have been?

0x2007,config word 1
0x2007,config word 2

If not, what?

Maybe this explains why my 886 is not behaving as expected.

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

Post by Benj »

Hello echase

You are right in your assumtion. The two config words go into sequential memory spaces.

0x2007 - Config1
0x2008 - Config2

If you wrote both of the config words to 0x2007 then you would simply overwrite the first config.

Post Reply