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

multi analog channel on 16c771

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 04, 2006 3:13 pm     Reply with quote

I don't have vs. 2.707. The closest I have is vs. 2.705. I made the
test program shown below and looked at the .LST file. The A/D
functions appear to produce the correct ASM code. This test program
is only for 8-bit A/D output, but it does show how to switch channels.
Try doing a simple program like this one, to see if you can get it
working with two A/D channels.
Code:

#include <16C771.h>
#fuses XT,NOWDT,PUT,BROWNOUT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_B1, rcv=PIN_B0)

#bit ADFM_BIT = 0x9F.7

void main()
{
int result_0;
int result_1;

setup_adc_ports(sAN0 | sAN1 | VSS_VDD);
setup_adc(ADC_CLOCK_DIV_64);

ADFM_BIT = 1;  // Right justify the result

while(TRUE)
 {
  set_adc_channel(0);
  delay_us(20);
  result_0 = read_adc();

  set_adc_channel(1);
  delay_us(20);
  result_1 = read_adc();
 
  printf("result 0 = %x\n\r", result_0);
  printf("result 1 = %x\n\r", result_1);
       
 }

}
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