Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ADC setpu in CCS c Code. How to do it?

Status
Not open for further replies.
Advanced Member level 6
Joined
Dec 4, 2012
Messages
4,280
Helped
822
Reputation
1,654
Reaction score
791
Trophy points
1,393
Location
Bangalore, India
Visit site
Activity points
0
I want to know how to setup adc ports in CCS C Compiler. I am using PIC16F887 MCU for the project. I will be using all the analog pins for adc and I will be using the Vref- and Vref+ pins for reference voltage. vref- will be connected to ground and vref+ will be given +2V.

I need an example for setup_adc_ports() function. What should be the arguments for the function? Should I define Vref somewhere else in the code?

I also want to disable the comparators on PORTA.
 

I want to know how to setup adc ports in CCS C Compiler. I am using PIC16F887 MCU for the project. I will be using all the analog pins for adc and I will be using the Vref- and Vref+ pins for reference voltage. vref- will be connected to ground and vref+ will be given +2V.

I need an example for setup_adc_ports() function. What should be the arguments for the function? Should I define Vref somewhere else in the code?
setup_adc_ports(sAN0|sAN1|sAN2|sAN3|sAN4|sAN5|sAN6|sAN7|sAN8|sAN9|sAN10|sAN11|sAN12|sAN13|VREF_VREF);
setup_adc(ADC_CLOCK_DIV_8);
I also want to disable the comparators on PORTA.
setup_comparator(NC_NC_NC_NC);
 

I tried that but it doesn't work. I gave 1.5V which is max value of LM35 output to AN0 and gave +2V to Vref+ pin and 0V to Vref- pin. for 2V it has to give 1023 raw adc value and for 1.5V it should give 767.25 raw adc value but it is not giving the right value.

Edit: I am getting 1023 raw adc value if I give 0V to Vref- and +2V to Vref+ and 1.5V to AN0
 
Last edited:

hello!!
which version of ccs c compiler do u use ?
-if you dont know how to code it, you should be able to chose analogical channels from the Wizard .
this is a simple example : setup_adc_ports(AN0_AN1_AN2_AN3_AN4); which means there are five adc channels .
-setup_adc_ports(AN0_AN1_AN2_AN4_AN5_AN6_AN7_VSS_); == VRef=A3
 

@DR.boy

My CCS C is v4.140. The latest vis 4.141

I will try setup_adc_ports(AN0_AN1_AN4_AN5_AN6_AN7_VSS_VDD); Will this take AN2 ad Vref- and AN3 as Vref+ ??

No. setup_adc_ports(AN0_AN1_AN2_AN4_AN5_AN6_AN7_VSS_); doesn't compile. It gives error.
 

hi
sorry for delay , i went and i back

try this
setup_adc_ports(AN0_AN1_AN4_AN5_AN6_AN7_VREF_VREF);

- - - Updated - - -


good luck !
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top