Page 1 of 1
discrepancy in work Flowcode and a crystal
Posted: Fri Sep 18, 2009 12:33 pm
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.
Re: discrepancy in work Flowcode and a crystal
Posted: Fri Sep 18, 2009 2:31 pm
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.
Re: discrepancy in work Flowcode and a crystal
Posted: Sat Sep 19, 2009 4:47 am
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.
Re: discrepancy in work Flowcode and a crystal
Posted: Sun Sep 20, 2009 1:44 pm
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.
Re: discrepancy in work Flowcode and a crystal
Posted: Mon Sep 21, 2009 2:57 pm
by Benj
Hello Leonid
According to the device datasheet writing 0x0F to ADCON1 will convert the pins to analogue inputs.

- ADC.JPG (105.46 KiB) Viewed 6846 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);
............
Re: discrepancy in work Flowcode and a crystal
Posted: Wed Sep 23, 2009 9:59 am
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.
Re: discrepancy in work Flowcode and a crystal
Posted: Wed Sep 23, 2009 12:59 pm
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.
Re: discrepancy in work Flowcode and a crystal
Posted: Wed Sep 23, 2009 5:58 pm
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.
Re: discrepancy in work Flowcode and a crystal
Posted: Thu Sep 24, 2009 9:01 am
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.
Re: discrepancy in work Flowcode and a crystal
Posted: Thu Sep 24, 2009 4:38 pm
by NOPROBLEM48
Thanks Benj!
Independently I could not find this line.
Yours faithfully, Leonid.