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 support@ccsinfo.com

18F14K22 using internal Vref selection X1?

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



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

18F14K22 using internal Vref selection X1?
PostPosted: Sat Nov 27, 2010 12:40 am     Reply with quote

I have the 18F14K22 that I want to use the internal Vref at 1.024 volts (x1). After looking through the 18F14K22.h file and the data sheet as well as reading the compiler manual on "setup_adc_ports()", I am still not clear on how I can set up those options. Do I need to actually go in and set the VREFCON0,1 and 2 registers myself or am I missing the obvious somewhere ? (I have the latest compiler 4.114). It is not clear to me exactly what the "setup_adc_ports()" function does and I don't see any references to the options I want in the .h file for that part. Yes, Google is my friend although I have beat it to death tonight I think :-) Clues or pointers to what I should have read would be much appreciated !

(I am going to swap this chip for the 16F690 chip in my PicKit2 board - the pinouts are the same, but setting the options is a bit different)

Thanks
mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 27, 2010 2:53 pm     Reply with quote

Apparently CCS didn't add support for setup_vref() for the 18F14K22.
It's not in vs. 4.114 either. I once did a work-around function for it,
but I didn't put in support for the internal Vref. I can possibly work
on it tomorrow and post it then.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sat Nov 27, 2010 3:45 pm     Reply with quote

OK, thanks for the info -- I can write to the registers so I can set it up, I just thought I was missing something obvious. I do notice that if I do a grep on the .h files to see what other .h files do have "constants used in setup_vref()" and there are lots of them. I have defined the registers in my code for that processor, so I'll just muddle on through :-)

Code:
// =======================================================//
#ELIF  PROCESSOR == "PIC18F14K22"
// *******************************************************//

//  PIC18F14K22 Processor specific stuff
#include <18F14K22.H>

// Define some registers we need access to ...
#BYTE VREFCON0 = 0xFBA  // Vref configuration registers
#BYTE VREFCON1 = 0xFBB
#BYTE VREFCON2 = 0xFBC

#BYTE ADCON0 = 0xFC2    // A/D converter config registers
#BYTE ADCON1 = 0xFC1
#BYTE ADCON2 = 0xFC0

#BYTE ANSEL  = 0xF7E     // Analog Select Registers
#BYTE ANSELH = 0xF7F

#ELSE  // should not get here - no processor defined
#ERROR ERROR ++++ INVALID or NO PROCESSOR SELECTED +++

#ENDIF


mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 27, 2010 4:46 pm     Reply with quote

Here is the setup_vref() I made before - except it does not support
the mode that you want (internal mode):
http://www.ccsinfo.com/forum/viewtopic.php?t=43155&start=6
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sat Nov 27, 2010 8:30 pm     Reply with quote

Thanks for the info -- looks like the same sort of numbers I had come up with. Have to experiment - got sidetracked today - had to replace the water pump in my wife's car. What is referred to as a "priority interrupt" Very Happy

It is interesting that many other chips in their list do have values for the setup_vref(). I don't know how their utilities use the information in the .h files - if I were to find the information for a different chip that matched the info for this one and added it to the .h file for the 18f14k22 would it then be able to use it or is there something hidden in one of the dll's etc that we don't know about ?

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 27, 2010 9:44 pm     Reply with quote

If the function parameters are not listed in the .h file, it's not going to
be supported in the DLL. CCS forgot to add it to that PIC.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sat Nov 27, 2010 10:14 pm     Reply with quote

OK, thanks - I was afraid there was a "man behind the curtain" involved that actually knew just where the things listed in the .h file went. Oh well, no big deal to set them myself since we know where the SFR's are that are involved. I guess I'll drop CCS support a note and see if they can add them in a future (hopefully sooner) release - that internal reference is handy especially if the supply is prone to a bit of fluctuation and the internal can be set to 1.024, 2.048 and 4.096 volts as a reference.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
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