PIC16F17xx ADC Components [Solved]

An area to discuss 8-bit PIC specific problems and examples

Moderator: Benj

Post Reply
User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

PIC16F17xx ADC Components [Solved]

Post by QMESAR »

Hi Team.

After fixing a few things on this device family we have the next issue ,
(1) you will see in the attachment the ADC is specified as 10 bit which it is not it is a 12 bit Converter.
(2) None of the ADC reads work ,I have tried them all on real HW (EB006 with various voltage at various AN pins)
Note I can see the captures in Ghost .

Please can you try to find a solution I need to capture AN0 -AN5 on a PIC16F1786 this is urgently now Please.I can get the ADC to work by manually setting it in a C call however as you know then I loose Ghost function as the ICD then loose track of the program ,I am not sure if this is an issue
or not however on a few projects I noticed that as long as you use FC componets the ICD will follow suite of the code once you add a C call then when running the ICD it rus but it ends up in the code somewhere which a person can not track

:D :D
Note below a capture of trying the Raw read however I tried All function calls none work on this chip.
Attachments
2.jpg
2.jpg (51.87 KiB) Viewed 6349 times
1.jpg
1.jpg (31.7 KiB) Viewed 6349 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: PIC16F17xx ADC Components

Post by QMESAR »

Hi Team

Besides the issue with the PIC17F1937 this issue is also still open with the ADC on the PIC16F17XX devices.
Here had a few issues
(1) Timer2 prescalers not allowing for 64 setting(fixed by Ben)
(2) UART Compile errors (fixed by Leigh)
(3) PWM error (fixed by Ben)
(4) ADC not working bit depth shown also incorrect it is a 12 bit converter.(Open)

ADC not working at all ,issue still open and I can not go forward with customer project ,just as a matter of interest the ICD/Ghost is working only about 5% it is unstable and not usable on this chip (Flowkit2 and EB006).The issue with the ICD is that you need to compile to chip several times before the ICD will connect after a reset and then when it is running and you pause and run again the famous popup message appear the Chip does not contain the latest build :D

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: PIC16F17xx ADC Components

Post by LeighM »

Hi,

I've had a look at the FCD and CAL code and I cannot yet see what the issues might be.
Despite the ADC component showing 10 bit, the correct 12 bit flag is generated. (I'll look into that separately)

Code: Select all

#define MX_ADC_BITS_12 
So the ADC functions should return 12 bits.

Could you post the C code that you use to get it working?

btw. Was that a typo about AN5? I don't see one on this 28 pin device.

Thanks!
Leigh

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: PIC16F17xx ADC Components

Post by QMESAR »

Hi leigh

yes that was a type I use AN0, AN1 and AN2.
I will post the C code as I am out of my office today at a customer location will update tomorrow.$
Thanks for looking at this

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: PIC16F17xx ADC Components

Post by QMESAR »

Hi Leigh.

Here is the MPLABx Project in which you will see the ADC is working ,I tried both 12bit and 10 bit conversions.
In Flow code what concerns me is that the ANSELA andANSEL B shows 0 and from MPLAB Code configuration ANSELA has 0xBF (only AN0 is configured so it is correct in my opinion.
FC_1.jpg
FC_1.jpg (44.94 KiB) Viewed 6309 times
As you see here the ADC is working and the values of the configuration registers.Note that it is possible to set 10 or 12 bit conversion on this chip with 2 complements or signed values as return from the ADC (Right and left justified) also I think FC set the ADCON2 register incorrectly which selects the ANDREF ADC Negative Reference VSS or a AN Channel
MPLAB.jpg
MPLAB.jpg (73.02 KiB) Viewed 6309 times
MPLAB project attached you can use it or the hex file to test if my findings are valid
FC_2.jpg
FC_2.jpg (76.43 KiB) Viewed 6309 times
Attachments
P16F1786_ADC.X.rar
(491.92 KiB) Downloaded 198 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: PIC16F17xx ADC Components

Post by QMESAR »

Leigh.
Here is a FC project which I included the settings for the ADC in a C call and it runs prefect ,however no go with the FC ADC component there
is certainly something wrong with it

:D
pic1023.jpg
pic1023.jpg (76.98 KiB) Viewed 6292 times
Attachments
FC Test Proj.rar
(68.07 KiB) Downloaded 188 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: PIC16F17xx ADC Components

Post by LeighM »

Hi,

Comparing your register settings with ours, two differences:
You have ADFM set, so result is in 2's compliment, not sign-magnitude
You have ADRMD set, result is 10 bit, not 12 bit
So the result meaning will be different.
I'll need to have a chat with Ben to see what we think about supporting these options

I think you have something of note with the...

Code: Select all

ADCON2 = 0x0F;
looks like that is needed to set the Negative Ref to be selected by ADNREF

Could you try just adding that one code line to the Flowcode component test?

Thanks
Leigh

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: PIC16F17xx ADC Components

Post by QMESAR »

Leigh
As I have pointed out this is the settings in my post I also pointed out that 12 bit mode works when I configure it in C code
I tried both 12bit and 10 bit conversions.
just read my post on about Mplab and you will see this however the standard 12bit signed mode in FC does not work I can set the ADC in C code up anyway I want and it is working :D

Both options is not the problem just get one working and signed mode is left justified and right justified options and it is working in MPLAB
The point remains when using the FC component for ADC it does not WORK ,and that is all we need if it is working with 12 bit signed conversion fine
just make the FC component to work.
Question did you ran FC code on a chip and variified the component is working I do not think so if you did you will see I am not trying to waste your time ,the component does simply not work and my exrecise demonstrated that by configuring the ADC manually it is working 10bit 12bit signed and 2 compliment I just do not have the time to document that all and post in the forum .

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: PIC16F17xx ADC Components

Post by Benj »

Hello,

I believe I might have made some progress on this problem.

I have now added a new ADC type in the CAL C code which now correctly assigns the negative reference as VSS.

I've also added the missing ADC channel 21 to the 40 pin devices and gone back through the ADC components and ensured the bit depth is now set correctly.

First extract the following files to your "Flowcode 7/components" folder.
components.zip
(59.14 KiB) Downloaded 204 times
Next extract the following files to your "Flowcode 7/FCD/PIC" folder.
PIC.zip
(36.74 KiB) Downloaded 182 times
Finally copy the file below to your "Flowcode 7/CAL/PIC" folder.
PIC_CAL_ADC.c
(124.36 KiB) Downloaded 197 times
Let us know how you get on.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: PIC16F17xx ADC Components

Post by QMESAR »

Hi Ben.

Thank you very much .This is appreciated I confirm that the ADC component with 12 bit resolution is working fine for me now .
:D :D :D
114.jpg
114.jpg (66.49 KiB) Viewed 6210 times

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: PIC16F17xx ADC Components [Solved]

Post by jgu1 »

Hi all!

I'm not hardcore. But do I understand this correct, is this new bugs?, Would you recommend all FC7 user to replace these files.

And again, I would be really happy If all corrected bug where placed in one lokation. :wink:

Thank` in advance.

Jorgen

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: PIC16F17xx ADC Components [Solved]

Post by Benj »

Hi Jorgen,

I would only advise the update if:

a) You are using the specific chip, CAL or component with a known bug that has been fixed
b) You are not working on a commercially sensitive project that is currently working with a looming deadline
c) You want to stay up to date with all the latest features and fixes.

I've now created a new updates since 7.3 topic here to simplify keeping up to date. Thanks for the prod to do the work :wink: it's one of those things that is very easy to put off until tomorrow and as we all know, tomorrow never comes.
viewtopic.php?f=63&t=19743

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: PIC16F17xx ADC Components [Solved]

Post by jgu1 »

Hi Ben!

Perfect, perfect Ben, thank you.
You must tell me if I am too annoying. I just want, and try to have my FC7's 100 % up to date. :D :D :D
I am very grateful to you for the effort you and the MM team are doing.

Maybe at next update, add this, if possible Martin´s nice creation of MAX7219 component from here: viewtopic.php?f=66&t=19356&start=25 working perfect.


Thank´s

Jorgen

Post Reply