Searching \ for '[PIC]: USING CCSC C COMPILER' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/languages.htm?key=c
Search entire site for: 'USING CCSC C COMPILER'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: USING CCSC C COMPILER'
2001\10\26@030625 by MATTHEWS, DEAN (D.)

picon face
TO ALL,

I INTEND TO USE THE CCSC C COMPILER TO PROGRAM A 16F877, DOES ANYONE KNOW WHERE I CAN FIND EXAMPLES OF C CODE FOR THIS COMPILER.  THERE HAS BEEN A LOT OF DISCUSSION RECENTLY USING A HITEC C COMPILER ON THE LIST, CAN I USE THE SAME CODE WRITTEN USING THE HITEC COMPILER FOR THE CCSC COMPILER.

Dean Matthews
Reliability Engineering
Ford Engine Plant Bridgend
South Wales, U.K
Tel No:(01656)672597
Fax No:(01656)672558
Email: spam_OUTdmatth14TakeThisOuTspamford.com
` Please consider your environmental responsibility before printing this e-mail


{Original Message removed}

2001\10\26@032236 by D Lloyd

flavicon
face
Hi

"I INTEND TO USE THE CCSC C COMPILER TO PROGRAM A 16F877, DOES ANYONE KNOW
WHERE I CAN FIND EXAMPLES OF C CODE FOR THIS COMPILER.  THERE HAS BEEN A
LOT OF DISCUSSION RECENTLY USING A HITEC C COMPILER ON THE LIST, CAN I USE
THE SAME CODE WRITTEN USING THE HITEC COMPILER FOR THE CCSC COMPILER."

There are some examples at "http://www.ccsinfo.com/examples.html" and AFAIK
you cannot use exactly the same C source written for the HiTEC C compiler
as (at least) I/O handling is different. Also, CCS supports a lot of "built
in" functions which HiTEC does not. Maybe you could wrapper things so they
would work in either compiler - I have not tried or used the HiTec
sufficiently to say one way or the other. I've used the CCS C compiler to
build small applications and found it to be very useful and increased
productivity somewhat; I'm not sure how "good" the inbuilt functions are in
terms of size as it is not possible to see the code they generated. I have
also tried the HiTec compiler but was put off as it is initially more time
consuming to do things due to the lack of driver support compared to CCS C.
An opinion based upon my laziness (well, lack of time) is perhaps not the
most objective, though ;-)

Regards,
Dan

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\10\26@065337 by dr. Imre Bartfai

flavicon
face
On Fri, 26 Oct 2001, D Lloyd wrote:
---[snip]----

> productivity somewhat; I'm not sure how "good" the inbuilt functions are in
> terms of size as it is not possible to see the code they generated. I have

It is very possible to see the code was being generated; the only thing
you should peek into is the .lst file. The quality of the code is pretty
good IMHO.

Regards,
Imre

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\10\26@073430 by D Lloyd

flavicon
face
Hi,

Dr Bartfai wrote:

"> productivity somewhat; I'm not sure how "good" the inbuilt functions are
in
> terms of size as it is not possible to see the code they generated. I
have

It is very possible to see the code was being generated; the only thing
you should peek into is the .lst file. The quality of the code is pretty
good IMHO."


Yeah -  correction to that - memory_loss.c occurred.. I "now" remember
seeing a lot of undocumented instructions at the start of the list file
which you can sift through if required.  Not that you need to, of
course......it's C - you don't need to understand what goes on after the
compiler has had it's way (cough) ;-)

Further to that (!) and a word of advice to the original poster is that one
thing about the CCS compiler (as with any compiler) it is often good to
rewrite sections of source code to see how it compiles it -  I found
significant differences between what the CCS compiler outputted for small
tweaks (50% savings in some areas). Better to write very simple C
statements as the compiler is much more likely to be able to work out an
optimal way of handling it (and humans reading it are much more likely to
understand, too)

Cheers,
Dan

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\10\26@095013 by James Paul
picon face
All,

I have used, (and still am using), the CCS C Compiler.  I'm very happy
with it and have had no major issues with it.  The built in functions
are relatively easy to use, and make for some quick coding. The resulting
object code is rather small, so the compiler is effecient.  And for the
price, you can't go wrong.   To be fair, I haven't had much contact with
the HITECH C compiler, so I can't say if I like it or not, but the cost
is what I was looking at when I bought my compiler.   I was doing PIC
programming at the time for use in hobby projects.  They found this out
at work, so now I do some programming for my employer.   I'm still not a
programmer by trade, but what programming I do, I use either assembly or
CCS C, depending on the requirements of the job and the complexity.
Bottom line, it's a good buy for the money, and you will like the ease
with which solutions can be coded.

                                                 Regards,

                                                    Jim




{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\10\29@053035 by MATTHEWS, DEAN (D.)

picon face
To all,

Does anybody have any example C programs using the CCSC compiler for using the onboard A2D converter on the PIC16F877.

Dean Matthews
Reliability Engineering
Ford Engine Plant Bridgend
South Wales, U.K
Tel No:(01656)672597
Fax No:(01656)672558
Email: .....dmatth14KILLspamspam@spam@ford.com
` Please consider your environmental responsibility before printing this e-mail


-----Original Message-----
From: James Paul [jamespspamKILLspamINTERTEX.NET]
Sent: 26 October 2001 04:48
To: .....PICLISTKILLspamspam.....MITVMA.MIT.EDU
Subject: Re: [PIC]: USING CCSC C COMPILER

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\10\29@070526 by D Lloyd

flavicon
face
Hi,

"Does anybody have any example C programs using the CCSC compiler for using
the onboard A2D converter on the PIC16F877."

A derivative of one of CCS' own examples - presumably they won't mind me posting it if they sell a compiler on the back of it ;-)

#use delay(clock=10000000)

void main (void)
{
  int value;

  setup_port_a( ALL_ANALOG );           // Next 3 lines are inbuilt functions
  setup_adc( ADC_CLOCK_INTERNAL );
  set_adc_channel( 0 );

  do {
        value = Read_ADC();
        delay_ms(100);
        printf("\n\r%2X\r\n", value);
  } while (TRUE);
}


Regards,
Dan

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\10\29@075433 by MATTHEWS, DEAN (D.)

picon face
Shouldnt the #use delay(clock=10000000) be 20000000 as I am using a 20MHz clock?
Also, the delay of 100ms.  Why have you chosen this, is it the time for the pic to register and process the analogue to digital conversion, so after 100mS it is ready to sample again?
I assume that the result of the conversion is stored in value. Say for example I nputed 2.5v into the PIC how can I actually see what this value is to ensure that the A2D is functioning correctly.


Dean Matthews
Reliability Engineering
Ford Engine Plant Bridgend
South Wales, U.K
Tel No:(01656)672597
Fax No:(01656)672558
Email: EraseMEdmatth14spam_OUTspamTakeThisOuTford.com
` Please consider your environmental responsibility before printing this e-mail


{Original Message removed}

2001\10\29@082700 by D Lloyd

flavicon
face
part 1 3941 bytes content-type:text/plain; charset=us-ascii
Hi,

Shouldnt the #use delay(clock=10000000) be 20000000 as I am using a 20MHz
clock?

* If your processor is running at 20MHz, then yes.

Also, the delay of 100ms.  Why have you chosen this, is it the time for the
pic to register and process the analogue to digital conversion, so after
100mS it is ready to sample again?

* You asked for some example code to show the CCS built-in functions and
that is what I posted - maybe I got the wrong end of the stick but you did
not ask for code for a specific application...Do you have the CCS compiler
already ? I posted that to show the "ease" of using the inbuilt
functionality with respect to on board hardware not to provide a solution.
The delay is simply there to allow the A2D conversion to take place - the
precise time it takes will be available in the PIC documentation. You could
poll the conversion complete flag (or get an interrupt) before getting the
value from the ADC - it's up to you.

I assume that the result of the conversion is stored in value. Say for
example I nputed 2.5v into the PIC how can I actually see what this value
is to ensure that the A2D is functioning correctly.

* With the CCS compiler, you can printf statements to redirect output
through the UART, via a serial cable (via a MAX232 etc) to a PC and use
Hyperterminal to monitor it. If you put 2.5V on the A2D (and it was
configured for 0-5V full range) then you would expect to see something like
"7F" coming up in Hyperterminal. The example code I posted omits the setup
of the serial port but it is as simple as :

#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)

Use then need to interface the PIC and PC via a MAX232 using these pins.

Regards,
Dan




(Embedded     "MATTHEWS, DEAN (D.)" <dmatth14spamspam_OUTFORD.COM>spamspam_OUTMITVMA.MIT.EDU>> image moved   29/10/2001 12:50
to file:
pic20803.pcx)





Please respond to pic microcontroller discussion list
     <
@spam@PICLISTKILLspamspamMITVMA.MIT.EDU>
Sent by:  pic microcontroller discussion list <KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU>


To:   RemoveMEPICLISTTakeThisOuTspamMITVMA.MIT.EDU
cc:
Subject:  Re: [PIC]: USING CCSC C COMPILER

Security Level:?         Internal


Shouldnt the #use delay(clock=10000000) be 20000000 as I am using a 20MHz
clock?
Also, the delay of 100ms.  Why have you chosen this, is it the time for the
pic to register and process the analogue to digital conversion, so after
100mS it is ready to sample again?
I assume that the result of the conversion is stored in value. Say for
example I nputed 2.5v into the PIC how can I actually see what this value
is to ensure that the A2D is functioning correctly.


Dean Matthews
Reliability Engineering
Ford Engine Plant Bridgend
South Wales, U.K
Tel No:(01656)672597
Fax No:(01656)672558
Email: spamBeGonedmatth14spamBeGonespamford.com
` Please consider your environmental responsibility before printing this
e-mail


{Original Message removed}
part 2 165 bytes content-type:application/octet-stream; (decode)

part 3 154 bytes
--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\10\29@083325 by Dale Botkin

flavicon
face
> Shouldnt the #use delay(clock=10000000) be 20000000 as I am using a 20MHz clock?

Yes.

> Also, the delay of 100ms.  Why have you chosen this, is it the time
> for the pic to register and process the analogue to digital
> conversion, so after 100mS it is ready to sample again?

Nope, it's just a loop delay - the PIC reads the ADC value and prints
every 100mS.  You could just as easily use a one-second delay or whatever.

> I assume that the result of the conversion is stored in value. Say for
> example I nputed 2.5v into the PIC how can I actually see what this
> value is to ensure that the A2D is functioning correctly.

In the example given, the line "value = Read_ADC();" will put the ADC
reading into the variable named "value".  Actually in that particular case
you'll only get an 8-bit result, since value is an int.  I would use a
long and make sure to set "#device PIC16F877 ADC=10" to get all 10 bits.
Here's a snippet of code from one of my projects that uses trhe ADC:

#device PIC16F877 *=16 ADC=10
#use delay (clock=20000000
#define volt_input 1                    // Analog input from VMM
#define amp_input 0                     // Analog input from shunt isolation amp
setup_adc_ports(A_ANALOG);              // Set up analog pins setup_adc_ports
                                       // (RA0_RA1_ANALOG_RA3_REF);
setup_adc(ADC_CLOCK_DIV_32);            // Set up ADC clock

temp = 0;
for(x=0;x<16;x++) {
       set_adc_channel(amp_input);
       delay_ms(1);                    // Chosen somewhat arbitrarily.
                                       // You actually only need a few
                                       // microseconds sample time.
       temp += read_adc();
}


What you'll get is a number from 0 to 1023, corresponding to the input
voltage compared to the reference voltage.  In other words, if Vref = 5V
and Vin = 2.5V, the ADC reading will be 512.

Hope this helps...

Dale

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\10\29@084412 by Dale Botkin

flavicon
face
> Also, the delay of 100ms.  Why have you chosen this, is it the time for the
> pic to register and process the analogue to digital conversion, so after
> 100mS it is ready to sample again?
>
> The delay is simply there to allow the A2D conversion to take place - the
> precise time it takes will be available in the PIC documentation. You could
> poll the conversion complete flag (or get an interrupt) before getting the
> value from the ADC - it's up to you.

Actually, read_adc() uses the GO/DONE bit and does all that on its own.
The delay between set_adc_channel() and read_adc() is just the A/D
conversion time.  You have to wait between ADC samples -- the formula for
determining the exact timing is in the data sheet, but a 1mS delay should
be more than adequate.  If I'm reading the data sheet right, 25uS would
probably be sufficient in most cases.  I just use 1mS since I know it's
plenty of time, and I don't need to sample any faster than that.

The PIC midrange manual AC section and the 16F877 data sheet have all the
timing information.  As for using CCS's built in functions, though, what
you've seen posted is pretty much it.  You just have to remember to allow
some delay between ADC samples, as read_adc() doesn't do it for you.

Dale

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\10\29@085203 by D Lloyd

flavicon
face
Hi,

> Also, the delay of 100ms.  Why have you chosen this, is it the time for
the
> pic to register and process the analogue to digital conversion, so after
> 100mS it is ready to sample again?
>
> The delay is simply there to allow the A2D conversion to take place - the
> precise time it takes will be available in the PIC documentation. You
could
> poll the conversion complete flag (or get an interrupt) before getting
the
> value from the ADC - it's up to you.

Actually, read_adc() uses the GO/DONE bit and does all that on its own.
The delay between set_adc_channel() and read_adc() is just the A/D
conversion time.  You have to wait between ADC samples -- the formula for
determining the exact timing is in the data sheet, but a 1mS delay should
be more than adequate.  If I'm reading the data sheet right, 25uS would
probably be sufficient in most cases.  I just use 1mS since I know it's
plenty of time, and I don't need to sample any faster than that.

The PIC midrange manual AC section and the 16F877 data sheet have all the
timing information.  As for using CCS's built in functions, though, what
you've seen posted is pretty much it.  You just have to remember to allow
some delay between ADC samples, as read_adc() doesn't do it for you.

> Pardon my ignorance on this one - I don't think I have used the A2D on
the PIC for yonks (I did some TCP/IP stuff with it) and certainly not with
the CCS compiler so I probably should not have advised(!) If the CCS
functions look after the flags then all the simpler (or less flexible
depending on how you look at it!)

Regards,
Dan

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\10\30@054612 by MATTHEWS, DEAN (D.)

picon face
Dan,

I tried to compile your example code with no success.  This is the code:

#device PIC16F877*16 ADC=10
#include<16F877.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)

void main (void)
{
  long value;

  setup_adc_ports(RA0_ANALOG_RA3_REF);           // This line I am having an error on
  setup_adc( ADC_CLOCK_INTERNAL );
  set_adc_channel( 0 );

  do {
        value = Read_ADC();
        delay_ms(100);
        printf("\n\r%3LX\r\n", value);
  } while (TRUE);
}


I saved the file as a .C file and then run it using the ccsc compiler.  I then opened up the error file and I had an error saying Unidentified identifier on the setup_adc_ports(RA0_ANALOG_RA3_REF); line.  I know I didnt say that I was using the PIC16f877 but I think that the terms inside the brackets are set up wrong for the PIC16F877.  Perhaps you were using a different PIC to me so your values in the brackets may be different.  What do you think?

Dean Matthews
Reliability Engineering
Ford Engine Plant Bridgend
South Wales, U.K
Tel No:(01656)672597
Fax No:(01656)672558
Email: TakeThisOuTdmatth14EraseMEspamspam_OUTford.com
` Please consider your environmental responsibility before printing this e-mail


{Original Message removed}

2001\10\31@144925 by briang

flavicon
face
In-Reply-To: <RemoveME200110300744.f9U7iet20095spamTakeThisOuTdymwsm10.mailwatch.com>

Dean,

> #device PIC16F877*16 ADC=10
> #include<16F877.h>

I always put

#include <16F877.h>
#device *=16 ADC=10


>   setup_adc_ports(RA0_ANALOG_RA3_REF);           // This line I am having an error on

You'll have to use RA0_RA1_ANALOG_RA3_REF if you use the 16F877.

Brian Gregory.
briangEraseMEspam.....cix.compulink.co.uk

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...