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
PIC12F1572 ADC problem (SOLVED)
Moderator: Benj
-
- Posts: 170
- Joined: Fri Jul 15, 2016 9:51 pm
- Has thanked: 69 times
- Been thanked: 61 times
- Contact:
PIC12F1572 ADC problem (SOLVED)
- Attachments
-
- ADC_test_with_2.5Vref.fcfx
- (10.14 KiB) Downloaded 265 times
-
- 8_pin allocation table.jpg (143.54 KiB) Viewed 5506 times
Last edited by Lagoda on Thu Sep 14, 2017 7:34 pm, edited 1 time in total.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: PIC12F1572 ADC problem
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
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:
Code: Select all
APFCON = APFCON | 4;
Add the following C code at the start of your flowchart(witin same block as OSCCON will be suffice):
Code: Select all
APFCON = APFCON | 132;
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
Code: Select all
SendChar 13
Code: Select all
SendChar 10
That makes each number appear on a new line
Martin
Martin
-
- Posts: 170
- Joined: Fri Jul 15, 2016 9:51 pm
- Has thanked: 69 times
- Been thanked: 61 times
- Contact:
Re: PIC12F1572 ADC problem
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
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
- Attachments
-
- ADC_test_with_2.5Vref_v2.fcfx
- (10.16 KiB) Downloaded 253 times
- 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: PIC12F1572 ADC problem
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.
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.
Code: Select all
FC_CAL_ADC_Enable(3, 3, 1, 40);
Let us know how you get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 170
- Joined: Fri Jul 15, 2016 9:51 pm
- Has thanked: 69 times
- Been thanked: 61 times
- Contact:
Re: PIC12F1572 ADC problem
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
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
- 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: PIC12F1572 ADC problem
Thanks for letting us know. I accidentally changed the settings in the DAC instead of the ADC.
Here is the corrected definition file.
Here is the corrected definition file.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel