discrepancy in work Flowcode and a crystal

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
User avatar
NOPROBLEM48
Posts: 30
Joined: Tue Nov 18, 2008 11:18 am

discrepancy in work Flowcode and a crystal

Post by NOPROBLEM48 »

Hello, everyone!
Has found out discrepancy in work Flowcode and a crystal. On a crystal entrance level on port And while simulation is correct is not fixed. I think, here business in any peripheral functions of a crystal, but itself I can not understand in what.
Yours faithfully, Leonid.
Attachments
V1.fcf
Attach
(5 KiB) Downloaded 293 times

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:

Re: discrepancy in work Flowcode and a crystal

Post by Benj »

Hello

Your program is set to use a clock speed of 5MHz.

Your initial C code block writes 0xFF to the osccon register. I don't think this is correct.

Your chip configuration settings are set to use an external clock source.

Use the View -> Project options and set the correct crystal speed.

Look at the device datasheet and calculate the correct value for the osccon register.

Use the Chip -> Configuration menu to assign the internal oscillator to the device.

User avatar
NOPROBLEM48
Posts: 30
Joined: Tue Nov 18, 2008 11:18 am

Re: discrepancy in work Flowcode and a crystal

Post by NOPROBLEM48 »

I am afraid, that your councils do not concern the given problem!
The crystal has clock speed 8 MHz as I and wanted, it is possible to be convinced of it, having looked work V2, here emulation Flowcode coincides with program work in a crystal. The problem being consists that program V1 is correctly emulated Flowcode but if it to program in a crystal change of a logic condition of port A is not perceived. I ask you to help to eliminate to me this discrepancy.
Yours faithfully, Leonid.
Attachments
V2.fcf
(5 KiB) Downloaded 276 times

User avatar
NOPROBLEM48
Posts: 30
Joined: Tue Nov 18, 2008 11:18 am

Re: discrepancy in work Flowcode and a crystal

Post by NOPROBLEM48 »

Has understood!
That the crystal worked how emulation Flowcode, it is necessary to disconnect inputs of converter A/D which coincide with A. For it it is necessary 0X0F to write down number in the register adcon1. It is made in program V3. It is correctly emulated Flowcode and works in a crystal.
Yours faithfully, Leonid.
Attachments
V3.fcf
(5.5 KiB) Downloaded 271 times

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:

Re: discrepancy in work Flowcode and a crystal

Post by Benj »

Hello Leonid

According to the device datasheet writing 0x0F to ADCON1 will convert the pins to analogue inputs.
ADC.JPG
ADC.JPG (105.46 KiB) Viewed 6845 times
If you look at the program C code then you have this.

Code: Select all

void main()
{
	//Initialisation
	adcon1 = 0x00;

	//C
	//C Code:
	osccon=0XFF;
	adcon1=0X0F;

	//Loop: While 1
	while (1)
	{
		//Input: A0 -> Me
		trisa = trisa | 0x01;
		FCV_ME = ((porta & 0x01) == 0x01);
                ............

User avatar
NOPROBLEM48
Posts: 30
Joined: Tue Nov 18, 2008 11:18 am

Re: discrepancy in work Flowcode and a crystal

Post by NOPROBLEM48 »

Excellently!
At me too is such (DS39758C from 2007), but there absolutely another is written. And, the most interesting, my chip works how is written in mine datasheet.
Yours faithfully, Leonid.
Attachments
PDF.jpg
(243.16 KiB) Downloaded 1370 times

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:

Re: discrepancy in work Flowcode and a crystal

Post by Benj »

Hi Lenoid

Hm so were both right and both wrong. Oh well I guess this chip must have been reversioned at some point.

If you like you can modify the initialiation line in the FCD file to match this alternate setting and this will allow you to create programs for your devices without having to add the line of C code at the start of your program.

User avatar
NOPROBLEM48
Posts: 30
Joined: Tue Nov 18, 2008 11:18 am

Re: discrepancy in work Flowcode and a crystal

Post by NOPROBLEM48 »

Thanks Benj!
You where in file 18F1330.fcd change to make could not prompt. I have seen it, but a place for this purpose have not found.
Yours faithfully, Leonid.

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:

Re: discrepancy in work Flowcode and a crystal

Post by Benj »

Hello Lenoid

This is the line on the FCD file you are looking for, its in the

Code: Select all

 section.

Initialise="adcon1 = 0x00;\n"

Change this to suit your chips.

Initialise="adcon1 = 0x0F;\n"

Then restart Flowcode and your chips will behaive correctly without needing to add the C code to the start of your program.

User avatar
NOPROBLEM48
Posts: 30
Joined: Tue Nov 18, 2008 11:18 am

Re: discrepancy in work Flowcode and a crystal

Post by NOPROBLEM48 »

Thanks Benj!
Independently I could not find this line.
Yours faithfully, Leonid.

Post Reply