CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

ADC setup

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
harlequin2



Joined: 11 Jun 2011
Posts: 21

View user's profile Send private message

ADC setup
PostPosted: Wed Mar 06, 2013 11:06 pm     Reply with quote

I am using a 16F1826 with V4.104 PCM and it won't allow me to set up the ADC reference with setup_adc_ports(sA0|VSS_FVR);
The compiler returns the errors "Undefined Identifier VSS_FVR" but it is defined in the header file. It seems to default to +5 V as the adc ref and I am unable to change it - unless I resort to assembler. Any clues as to why the compiler fails?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 06, 2013 11:40 pm     Reply with quote

Quote:
setup_adc_ports(sA0|VSS_FVR);

Compare the parameter in bold to those listed in the 16F1826.h file.
Is it correct ?
harlequin2



Joined: 11 Jun 2011
Posts: 21

View user's profile Send private message

PostPosted: Wed Mar 06, 2013 11:43 pm     Reply with quote

Yes, that is correct. I note that the PCM.htl file shows it simply as A0, but the .h file shows sA0 so that is what I used.
It compiles OK if I leave out the VSS_FVR.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 06, 2013 11:51 pm     Reply with quote

What is an .htl file ? I have no idea.
Here is part of the 16F1826.h file for vs. 4.104, and it has sAN0, not sA0.
I agree that it doesn't have VSS_FVR:
Code:

// Constants used in SETUP_ADC_PORTS() are:
#define ALL_ANALOG  0xffff0007     // A0 A1 A2 A3 A5 B0 B1 B2 B3 B4 B5 
#define sAN13         0x20000000    // B5
#define sAN12         0x01000000    // B0
#define sAN11         0x10000000    // B4
#define sAN10         0x02000000    // B1
#define sAN9          0x08000000    // B3
#define sAN8          0x04000000    // B2
#define sAN4                0x20    // A5
#define sAN3                 0x8    // A3
#define sAN2                 0x4    // A2
#define sAN1                 0x2    // A1
#define sAN0                 0x1    // A0
#define NO_ANALOGS       0x00000    // None

// One of the following may be OR'ed in with the above using |
#define VSS_VDD              0x0000        //| Range 0-Vdd
#define VSS_VREF             0x0200        //| Range 0-Vref
#define VSS_1V024            0x1200        //| Range 0-1.024V
#define VSS_2V048            0x2200        //| Range 0-2.048V
#define VSS_4V096            0x3200        //| Range 0-4.096V
harlequin2



Joined: 11 Jun 2011
Posts: 21

View user's profile Send private message

PostPosted: Thu Mar 07, 2013 12:39 am     Reply with quote

Sorry, my typo, htm.
That other stuff is not in my 16F1826.h file.
Perhaps I'll try that? But why do the definitions in the .h file that I have not work?
Here is the relevant section from my .h file:
Code:
// Constants used in SETUP_ADC_PORTS() are:
// First argument:
// OR together desired pins
#define sAN0            0x000100    // A0
#define sAN1            0x000200    // A1
#define sAN2            0x000400    // A2
#define sAN3            0x000800    // A3
#define sAN4            0x001000    // A4
#define sAN5            0x000040    // B6
#define sAN6            0x000080    // B7
#define sAN7            0x000020    // B5
#define sAN8            0x000010    // B4
#define sAN9            0x000008    // B3
#define sAN10           0x000004    // B2
#define sAN11           0x000002    // B1
#define NO_ANALOGS             0    // None
#define ALL_ANALOG      0x001FFE    // A0 A1 A2 A3 A4 B6 B7 B5 B4 B3 B2 B1

// Optional Second argument:
#define VSS_VDD         0x000000    //| Range 0-Vdd
#define VSS_VREF        0x020000    //| Range 0-VrefH
#define VSS_FVR         0x030000    //| Range 0-Fixed Voltage Reference
#define VREF_VDD        0x040000    //| Range VrefL-Vdd
#define VREF_VREF       0x060000    //| Range VrefL-VrefH
#define VREF_FVR        0x070000    //| Range VrefL-Fixed Voltage Reference

// Constants used in READ_ADC() are:
#define ADC_START_AND_READ     7   // This is the default if nothing is specified
#define ADC_START_ONLY         1
#define ADC_READ_ONLY          6


By the way, none of the "second argument" valuse work, all the same "undefined ...." error.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 07, 2013 12:45 am     Reply with quote

Compile a file so that it compiles without errors. (Comment out any line
that causes errors). Then look at the top of the .LST file in your project
directory. What version is listed there ?
harlequin2



Joined: 11 Jun 2011
Posts: 21

View user's profile Send private message

PostPosted: Thu Mar 07, 2013 12:49 am     Reply with quote

V 4.104
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 07, 2013 1:46 am     Reply with quote

I just don't believe that your 16F1826.h file is the real one from vs. 4.104.
Unless CCS put out more than one sub-version of 4.104, which they have
been known to do on occasion.

I have the command line PCM compilers. I opened a Command Prompt
window and did a directory on it. Here's the info for my install file:
Quote:
PCM4104.EXE 5,658,656 12-29-09 10:20a pcm4104.exe

The date and time are simply the date and time that I downloaded the
file. But it would have been shortly after it was posted. Maybe the same day.

If I right-click on the icon for pcm4104.exe in Windows, and click on
Properites in the pop-up menu, it give me this information:
Quote:

File version 4.104.29.11


What do you get if you do all of this ? I'm trying to establish if we really
have the same "pcm vs. 4.104" or not.
harlequin2



Joined: 11 Jun 2011
Posts: 21

View user's profile Send private message

PostPosted: Thu Mar 07, 2013 7:25 pm     Reply with quote

Thank you, you got me thinking, especially about the message "Undefined label" or whatever it was. It seemed to me that the compiler was not using the correct header file, so I searched for instances of 16F1826.h and lo and behold, there was a very old version in the actual project directory which the compiler was finding first. Deleted it and now the compiler finds the correct one in the place that it should be - "Devices" folder in the PICC directory.
My apologies for raising such a red herring, all down to lousy housekeeping on my part.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group