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 program help needed

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



Joined: 17 Aug 2011
Posts: 1

View user's profile Send private message

ADC program help needed
PostPosted: Wed Aug 17, 2011 12:47 pm     Reply with quote

Here I am trying to do A/D conversion and transfer the data to putty, to see the output but it seems it's not working. Need your help guys.........

My code:
Code:

#include <htc.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

main()
{

int j,x,y,z;
OSCCON=0x70;
CMCON0=0X07;  //turn off comparator
TRISA=0X01;   //input port
ADCON1=0X50;  //fosc/16
ADCON0=0x81; // right justufied
INTCON=0X00;
ANSEL=0x01;// select channel
TMR2=0X00;    //clear tmr2
TRISB=0x00;
PORTB=0x00;
TRISC = 0x00;//
PORTC = 0x00;                    // CLEAR DATA LATCH
//TXSTA=0x24;               
T2CON = 0x04;               // POSTSCALER 1:1, PRESCALER 1:1, TIMER2 ON
//serial communication
      RCSTA=0X80;
      SPBRG=0x0C; //baudrate 9600
      PIE1=0X00;
   //   TXSTA=0X20;
while(1)
   {
for (j=1; j<3;j++)
{
      
      ANSEL=j;
   if(j==1)
      {
        ADCON0=0x81;
                   }
      else{
              ADCON0=0x85;
                      }
ADCON0=ADCON0|0X02;
         
   if ((ADCON0&0x02)!=0X02)
         {
            TXREG=ADRESL;
                                                                 TXSTA=0x20;         
            
            
if((TXSTA&0X22)!=0X22);
                  TXREG=ADRESH;
   TXSTA=0X20;
   
      if((TXSTA&0X22)!=0X22); //hold till tx completess
}
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 17, 2011 12:56 pm     Reply with quote

Quote:
#include <htc.h>

Your program is written for the Hi-Tech C compiler. This forum is for
the CCS compiler. You need to ask your questions on the Hi-Tech forum:
http://forum.htsoft.com/all/ubbthreads.php

Also, Microchip has a Hi-Tech compiler forum:
http://www.microchip.com/forums/tt.aspx?forumid=231
temtronic



Joined: 01 Jul 2010
Posts: 9220
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Aug 17, 2011 1:43 pm     Reply with quote

or...

you could just use the example in the ccs C compiler examples folder as a basis of using CCS C, then you will get help here !
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Aug 17, 2011 3:11 pm     Reply with quote

I have believed for a LONG time - after trying it - initially -
that it is so simplistically assembler derived -
that LOW tech C was a much more apt name.

I started work with PICs in assembler - and LOWtech C
was just not enough of an improvement for me to bother with.

and the lowtech forum?? whew - blind leading blind ... ;-))

just my 2 cents
bkamen



Joined: 07 Jan 2004
Posts: 1614
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Aug 18, 2011 3:52 pm     Reply with quote

asmboy wrote:

and the lowtech forum?? whew - blind leading blind ... ;-))

just my 2 cents


Asm, you crack me up.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
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