Page 1 of 1
PIC12F1572 ADC problem (SOLVED)
Posted: Wed Sep 13, 2017 8:27 pm
by Lagoda
Hi All,
I would like to use ADC and UART modul of PIC12F1572.
The problem is that +Vref pin of ADC and Rx pin of UART are same pins and I can not setup Alternate pin function in Flowcode7.
The +Vref pin is not active.
Can I get some help?
Best Regards,
Lagoda
Re: PIC12F1572 ADC problem
Posted: Thu Sep 14, 2017 1:09 am
by medelec35
Hi Lagoda,
To set-up alternative pins, first look at the datasheet on page 101:
See which pin you want to change the function of.
E.g TX which is what your currently using (not RX) from pin RA0 to RA4
Work out the required value = 4 as it's bit 2.
Add the following C code at the start of your flowchart:
If you want to change both RX and TX = bits 2 and 7 = 4 + 128 = 132
Add the following C code at the start of your flowchart(witin same block as OSCCON will be suffice):
etc.
Also, you don't want to sendChar as when the AD value is 32 then you are sending a space and not the number 32.
You should use SendNumber instead.
You may also want a space between numbers.
What I do is after sending a number I use
and
That makes each number appear on a new line
Martin
Re: PIC12F1572 ADC problem
Posted: Thu Sep 14, 2017 10:01 am
by Lagoda
Hi Martin,
Thank you for your advices.
I modified the flowchart.
The Rx function of the UART is on the RA5 now.
But the "Vref+" pin is inactive, the ADC working with VDD reference.
Do you have any idea?
Best regards,
Lagoda
Re: PIC12F1572 ADC problem
Posted: Thu Sep 14, 2017 10:54 am
by Benj
Hi Lagoda,
I think I have found the problem. Please can you try copying the attached file into your "Flowcode 7/FCD/PIC" folder.
Restart Flowcode and load your project and check that the ADC component properties are still set to Vref+, it might have changed thanks to the FCD changes.
Hopefully this should now work for you.
You can check by looking at the generated C code around line 629.
If all has worked correctly then the 1 should now be a 2.
Let us know how you get on.
Re: PIC12F1572 ADC problem
Posted: Thu Sep 14, 2017 11:55 am
by Lagoda
Hi Ben,
Thank you for your help.
Unfortunately, the problem remains.
If i set the reference VDD then in the line 626 is: FC_CAL_ADC_Enable(3, 3, 0, 40);
If i set the reference Vref+ then in the line 626 is: FC_CAL_ADC_Enable(3, 3, 1, 40);
Best Regards,
Lagoda
Re: PIC12F1572 ADC problem
Posted: Thu Sep 14, 2017 1:00 pm
by Benj
Thanks for letting us know. I accidentally changed the settings in the DAC instead of the ADC.
Here is the corrected definition file.
Re: PIC12F1572 ADC problem
Posted: Thu Sep 14, 2017 1:31 pm
by Lagoda
And it works well !!!
Thank you very much!
Lagoda