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

ADC pic 12f683

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



Joined: 20 Jun 2014
Posts: 14

View user's profile Send private message

ADC pic 12f683
PostPosted: Sat Jun 21, 2014 3:57 am     Reply with quote

Please help i´m begginner in c

i need use 10 bit adc i have ccs c version 5.0.17
My problem is maybe in adc because if i give on pin AN3 voltage 0,1 to 5V output is allways to low but if i give 0V to AN3 output is high.


I need this:

IF i have on AN3 - 0 - 2,5 V output is low and 2,55-5V i need output high.
I need use "r" because with "r" i need change delay later.


My Code:



#include <abs-c.h>
#include <stdio.h>
#use delay(clock=4000000)
#fuses HS,INTRC_IO,NOWDT, NOPUT, NOMCLR, NOBROWNOUT

#byte TRISIO = 0b00010000 // GP4 is an input (GP4 = AN3 for pic12f683)

#byte GPIO = 0x00 // set GPIO to low outputs
#byte ANSEL = 0b01111000 // ANS3 as analog input, Frc (internal clk )
#byte ADCON0 = 0b10001101 //right justified, vdd, -, -, 11=an3, 0=done, 0=adon on
#byte ADON=1 // turn on the A2D conversion module
#byte CMCON = 7 //Turn off comparator

void main()
{

int16 r;

setup_adc_ports(sAN3);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(3);
delay_ms(10);

while (True)

{

r = read_adc();
If (r >=500) {
output_low(PIN_A0);}
else if(r < 500)
{output_high (PIN_A0);}
delay_ms(10);


}

}
peterzatko



Joined: 20 Jun 2014
Posts: 14

View user's profile Send private message

Re: ADC pic 12f683
PostPosted: Sat Jun 21, 2014 4:50 am     Reply with quote

any idea????
peterzatko



Joined: 20 Jun 2014
Posts: 14

View user's profile Send private message

Re: ADC pic 12f683
PostPosted: Sat Jun 21, 2014 5:05 am     Reply with quote

Problem solved i have set in h. device ADC=16 i change to 10.
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