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

PIC 18 - ADC Setup

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



Joined: 28 Jul 2015
Posts: 4
Location: Argentina

View user's profile Send private message

PIC 18 - ADC Setup
PostPosted: Tue Jul 28, 2015 10:59 am     Reply with quote

Hi, I'm working on a project on MPLAB 8.92 using a PIC18F46K22 and I'm having an issue with my ADC setup. I had this project working on another computer but when I tried to compile it on mine, it threw an "expecting a close paren" error on this line:
Code:
setup_adc_ports(sAN0|sAN1, VSS_FVR);

I'm assuming the function prototype differs from the one in the other computer's CCS since this will compile and work:
Code:
setup_adc_ports(sAN0|sAN1 | VSS_FVR);

However I'm not sure this would be correct. The OR operations with those parameters don't overlap, but I don't know if setup_adc_ports() will even take VSS_FVR into consideration and my hardware is now overheating (ADC is being used to control a microstepping motor).

How can I properly setup the ADC module including VSS_FVR?

Aditionally, my CCS won't recognize #fuses CCP2C0, which I changed for CCP2C1 following the microcontroller datasheet... is that correct? Why is CCP2C0 undefined in my CCS but not on the other computer? What should I be updating on my computer to have the same defines/functions/etcs as the other one?

Thank you for any help!
_________________
Nic
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Jul 28, 2015 1:21 pm     Reply with quote

setup_adc_ports(THIS, WTF? ); per the CCS manual counts
as TWO arguments
and the CCS manual shows one argument with NO commas -

just the one argument with ORing
wishing the compiler worked to your taste won't get it done.
the comma is not expected so of course an error as you see.
-----------------
what compiler version do you have?
-----------------
and as to : CCP2C0 IT IS INVALID on TWO counts

1) you can't arbitrarily make up fuses for CCS
AND
2) the part could not provide the function to C0 anyway.
READ the datasheet pinout to see why

only C1 works in the hardware.......
adjust your design to make it so and use the supported #fuse

you are simply wrong twice over
Nikel



Joined: 28 Jul 2015
Posts: 4
Location: Argentina

View user's profile Send private message

PostPosted: Tue Jul 28, 2015 2:03 pm     Reply with quote

Well, that's exactly what I'm trying to clarify! Maybe I explained it poorly... I'm working on a project a coworker wrote. He quit, I got more work. So now I'm setting up my computer and when I compile the project, I get these errors.

Reading datasheets and manuals I haven't found a setup_adc_ports() with 2 arguments, yet a call to such function will compile on my coworker's machine!! And so will a declaration of #fuses with CCP2C0!! I'm not wishing for anything, I'm only stating that I found those problems, they will compile on another machine, they (naturally) won't on mine, and I'm trying to understand the why's of the situation. Probably some weird library he installed? Eventually, I don't care about the why's, but I do need to know how to replace those declarations with a correct call.

So, will a call to setup_adc_ports() with only 1 argument (as it should be!) with an OR including VSS_FVR work as I expect it to? If not, how do I set that up? (As I said, ADC value is used as input for a PID that regulates current on a Motor, and I now notice overheating, so I suspect I have to do something differently.)

Finally, would CCP2C1 be the proper replacement for what I had originally? For what I have read, it is, but just wanted to check and be sure.

Thanks for your answer!
_________________
Nic
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 28, 2015 2:12 pm     Reply with quote

Quote:
but when I tried to compile it on mine, it threw an "expecting a close paren" error on this line:

Post your CCS compiler version. It's a 4-digit number given at the top
of the .LST file after a successful compilation. The .LST file will be in
your project directory. Example of version numbers:
http://www.ccsinfo.com/devices.php?page=versioninfo
Nikel



Joined: 28 Jul 2015
Posts: 4
Location: Argentina

View user's profile Send private message

PostPosted: Tue Jul 28, 2015 2:24 pm     Reply with quote

Sorry, forgot about that.

Mine is "CCS PCH C Compiler, Version 4.109, 38426" (from my last Main.lst build)
_________________
Nic
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Wed Jul 29, 2015 2:18 am     Reply with quote

Optional dual variable setup of the ADC, appeared with V5 compilers. These have:

Code:

_bif void setup_adc_ports(int32 pins);
_bif void setup_adc_ports(int32 pins, int32 reference);

//and in the defines:
// Optional Second argument:


With the second form allowing the reference to be specified as a second variable.

So the code you have is for a V5 compiler.

Then CCP2C0. This is a mis-spelling on some of the recent compilers. It correctly sets CCP2C1....
Nikel



Joined: 28 Jul 2015
Posts: 4
Location: Argentina

View user's profile Send private message

PostPosted: Wed Jul 29, 2015 2:18 pm     Reply with quote

Well... that would explain it! Thank you so much for that!

So what would the 4.x version of
Code:
setup_adc_ports(int32 pins, int32 reference);
for setting the reference be?

As I said on my first post, I've tried with
Code:
setup_adc_ports(sAN0|sAN1 | VSS_FVR);
but it looks like it's not working, since I'm not getting the expected behaviour (which I do get if I compile and program on the other computer)
_________________
Nic
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