First flowcode program

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
djm2
Posts: 18
Joined: Tue Jan 24, 2012 6:12 pm
Has thanked: 1 time
Contact:

First flowcode program

Post by djm2 »

Hi there

I have flowcode 5 and have been trying to get a very simple program to turn on an LED on a PIC with no success.

PIC18F452
Hardware platform - SBC44B http://www.modtronix.com/product_info.p ... cts_id=109
Programming with a ICD2 programmer through MPLAB
10MHz crystal

I have attached the flowcode program I create to turn on a LED connected to Port B6. The program compiles down to .hex with no problems. Then I program the board with MPLAB and the ICD2 again with no problems. I have checked the configuration settings for the device in the flowcode program. Watchdog - Off, Low Voltage programming - off, brown out detection - off I set the clock frequency to 10Mhz. I also set the oscillator to HS and also tried HS-PLL.

I have found that flowcode never seems to remember the oscilator settings ie it always goes back to "RC-OSC2 as RA6" ("configure the chip" tick box is ticked). I guess that this could be my problem but I have no way of fixing it as the software wont let me change it and save it. I have tried changing the config in MPLAB to HS/HS-PLL but this doesnt work - not sure if it should work like that though.

I wrote a program in C18 to turn the same port on and the program works fine so the hardware side of things is OK. Is there a known bug about this?

I have attached the flowcode files for the program I created.

Code: Select all

#include <p18cxxx.h>

void main(void);


void main(void)
{
	LATB = 0x00;
	TRISB = 0b00000000;
	PORTBbits.RB6 = 0;

    while(1)
	{	
	                PORTBbits.RB6 = 1;
	}
}
David
Attachments
flowcode test.zip
Turn on PortB,6 program
(76.6 KiB) Downloaded 273 times

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: First flowcode program

Post by medelec35 »

Hi David not sure why the configuration settings are not being saved. I believe its a minor bug and is not your fault.
So as a way around, I have modified 18F452 with preset configuration settings.
I had to guess what configuration settings you wanted, so if you want any done differently then let me know.

First keep a back of copy copy of your original 18F452.fcd that's in:
C:\Program Files (x86)\Flowcode\v5\FCD
for 64bit windows
or
C:\Program Files\Flowcode\v5\FCD
for 32bit windows

Then replace the original file with attached 18F452.fcd file.

Then next time you open your Flowchart, fingers crossed the correct configuration settings will be set.

Can you let me know if that works please.

Thanks

Martin
Attachments
18F452.fcd
(15.1 KiB) Downloaded 271 times
Martin

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: First flowcode program

Post by JonnyW »

Hello. Looking at the hex file it appears that the config words are there, but some of them are masked off - CONFIG1H is 0xFF (instead of 0x27 according to PPP). This is the same in the generated C code.

I'm sure Martins fix will get you sorted. However, if you need to change these settings manually for any reason, you can turn off PPP and edit the settings directly.

If you go into Menu->Build->Compiler Options...->Programmer and uncheck the 'Use external program to set configuration options' checkbox, then entering the programs config settings will allow you to enter whatever values you would like. These settings are subject to no additional logic so what you enter is what will be set.

You can verify the settings before compile by going to Build->View C... and looking around line 90 (for your build) for code that looks like this:

Code: Select all

#ifdef _BOOSTC

#pragma DATA 0x300000, 0xff

#endif
The 0x300000 is the address that will be written to, and 0xff is the hex value written to this.

I hope this is useful.

Jonny

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: First flowcode program

Post by medelec35 »

One other thing.
when you load your flowchart and configuration settings look correct,
if you should change just one of the settings manually, then all the settings will revert back to watchdog timer & LVP enabled, osc back to RC etc.
If that happens, Choose a random target in Build, Project options, then re-choose 18F452.
Then setting will revert back to OSC HS, WDT & LVP disabled etc.

Martin
Martin

djm2
Posts: 18
Joined: Tue Jan 24, 2012 6:12 pm
Has thanked: 1 time
Contact:

Re: First flowcode program

Post by djm2 »

Hi there

Thanks for your replies.

Changing the did not appear to work. I worked as it did before. I saw you had added some extra lines regarding the config words and I tried playing about with these but could not get it to work.

I also tried swapping the PIC for a PIC18f458 with the same result.

I tried configuring manually ie disable the PPP again I had the same results. I started off with the following config in Flowcode -

0x300002,0x7
0x300003,0xe
0x300006,0x85
0x300009,0xc0
0x30000a,0x3
0x30000b,0xe0
0x30000c,0x3
0x30000d,0x40

In the .asm file I ended up with -

ORG 0x00300000
DW 0xFFFF
DW 0x0E07
DW 0xFFFF
DW 0xFF85
DW 0xC0FF
DW 0xE003
DW 0x4003

I may be wrong here but I would have expected an entry for 0x300001 in flowcode which I added but it did not turn up in the .asm file. When I manually eddited the .asm to the following my program worked! -

DW 0xFAFF
DW 0x0E07
DW 0xFFFF
DW 0xFF85
DW 0xC0FF
DW 0xE003
DW 0x4003

Is this a known issue?

David

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: First flowcode program

Post by JonnyW »

Hi. To let you know, the problem was in reading the settings specifically from PPP - this uses the registry to return settings and some of these reads were failing. This will be fixed in the next release.

If you have added the settings manually (without PPP) and this still fails, this is a separate issue. Can you post the FCF file and C source file with these settings added manually and we can check if they are being added to the C code OK? If they are then something in the BoostC compiler is preventing them, and if they are not then there is another issue in Flowcode. When I try adding words without PPP the ASM inserts OK.

Thank you for your time,

Jonny

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: First flowcode program

Post by medelec35 »

Hi David,
I compiled to hex using the way I recommend, and I can confirm the configurations settings set in the hex file is correct.
Confirmed by loading hex file in mplab.
Here is a screen shot:
configuration set in file.png
(60.46 KiB) Downloaded 1890 times
I have also attached all the compiled files.

What i would recommend is if you open your flowchart, and check configuration has OSC set for HS.
if not choose a random target, and then re choose 18F452.
Check osc again and if HS is showing just use Cancel.
If you alter any other configuration settings, or even press OK when on expert configuration screen, then all setting will revert to the settings you do not want.
I suspect that could have happened.

Note The 18F452 posted above is only a temporally fix until official fix is posted.

Martin
Attachments
Flowcode2.zip
(69.64 KiB) Downloaded 265 times
Martin

djm2
Posts: 18
Joined: Tue Jan 24, 2012 6:12 pm
Has thanked: 1 time
Contact:

Re: First flowcode program

Post by djm2 »

Hi there

I was sure that I had tried changing the settings without the PPP before and it didnt work but I just tried again and it did. If it means anything when you open the window to config the chip the first line is missing and has to be added manually. Once I did it compiles do to C and then down to the asemblier file.

Thanks for looking at that it seems that you are correct. As you said if you change anything then it reverts back to the default settings. I have just tried playing about with other chips there and it seems as if it is not just the PIC18F452. I have tried 2 other random chips and they do the same thing.

David

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: First flowcode program

Post by JonnyW »

djm2 wrote:If it means anything when you open the window to config the chip the first line is missing and has to be added manually.
Hi David. Yes, if Flowcode thinks the setting is not set then it will omit the line rather than show a meaningless value.

This bug will unfortunately affect chips seemingly at random - the problem is not with the chip definition files but with the Flowcode executable itself when it pulls the data back from PPP. This will be fixed in the next release.

Jonny

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

Re: First flowcode program

Post by Steve »

A temporary fix for this can be found here:
http://www.matrixmultimedia.com/mmforum ... 46&t=10112

Post Reply