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 with sleep()

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



Joined: 04 Oct 2003
Posts: 3

View user's profile Send private message

ADC with sleep()
PostPosted: Tue Oct 07, 2003 4:29 am     Reply with quote

Hi,
Does anybody have a code sample for using the ADC with sleep().
I have PCM 3.178 and am using a 16F88 at 10Mhz. I have read
through the samples and the manual and also previous posts,
but I am still unclear on using sleep() with #int_ad.

Thanks in advance,
Kevin
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Tue Oct 07, 2003 5:04 am     Reply with quote

When you went through the previous posts, did you come across this one?
http://www.ccsinfo.com/forum/viewtopic.php?t=16818&highlight=adc+sleep

It seems to explain everything.
kben



Joined: 04 Oct 2003
Posts: 3

View user's profile Send private message

PostPosted: Tue Oct 07, 2003 6:59 am     Reply with quote

I was hoping I did not have to jump through all the hoops to get the compiler to do what it is supposed to in the first place. I did see that,
I just thought if I had the latest version there might be an easier way.
I guess I will define all the bit flags and give it a go.
Thanks.
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Tue Oct 07, 2003 5:22 pm     Reply with quote

Remember, if you are using one of the newer versions of the compiler you won't need to adjust PEIE yourself.
kben



Joined: 04 Oct 2003
Posts: 3

View user's profile Send private message

PostPosted: Fri Oct 10, 2003 8:15 pm     Reply with quote

Thanks Haplo & RJ, I used the link you provided above and go it to work.
I am using v3.178 with a 16F88 and I DID have to set PEIE manually.
My code looks like this:
//************************ Used for setting ADC Interupt**
#byte ADRESL = 0x9E
#byte ADRESH = 0x1E
#bit ADGO = 0x1f.2
#bit ADON = 0x1f.0
#bit ADIF = 0xC.6
#bit PEIE = 0xB.6
//********************************************************
void main(void) {
// Set up ADC for measuring current and temperature
enable_interrupts(INT_AD);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports( sAN0 | sAN1 | VSS_VDD );
// Use RA0 and RA1 for ADC ref = VREF 0-5V

While(TRUE) {

enable_interrupts(GLOBAL);
set_adc_channel(0);
ADON=TRUE;
delay_us (10);
disable_interrupts(GLOBAL);
enable_interrupts(INT_AD);
PEIE=TRUE;
ADIF=FALSE;
ADGO=TRUE;
printf("\r\nGoing to sleep\r\n"); // Test
sleep();
printf("\r\nWaking from sleep\r\n"); // Test
value1=make16(ADRESH,ADRESL);
disable_interrupts(INT_AD);
enable_interrupts(GLOBAL);
printf("\r\nValue returned for ADC Channel 1: %lu ",value1);

} // End While Statement Block

} // End of Main Program
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