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

Looking for basic tutorial

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



Joined: 03 Mar 2008
Posts: 55

View user's profile Send private message

Looking for basic tutorial
PostPosted: Mon Mar 03, 2008 4:23 am     Reply with quote

plop,

i'm using a 16F877A and CCS 4.057.
i'm looking for basic tutorial, like how to configure inputs and outputs, how to put something on those outputs, how to use an ADC.
until now i was using flowcode but it doesn't suit my needs, (i need to do stuff like var = 10.81^(-0.1661) ) so i need to do real C, i know how to do C, but not C for PIC.
can you help me?

thanks
_________________
yup, i know, i don't speak english very well

CCS V4.057
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 03, 2008 12:28 pm     Reply with quote

Quote:
i need to do stuff like var = 10.81^(-0.1661) ) so i need to do real C


Just that one operation uses 1/4 of the entire ROM in your PIC.
Here's the .LST file output for the test program shown below.
Code:

CCS PCM C Compiler, Version 4.068, xxxxx       03-Mar-08 10:23

               Filename: pcm_test.lst

               ROM used: 1992 words (24%)
                         Largest free fragment is 2048
               RAM used: 18 (5%) at main() level
                         71 (19%) worst case
               Stack:    3 locations

Code:

#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#include <math.h>
//======================================
void main()
{
float x, y, result;

x = 10.81;
y = -0.1661;

result = pow(x, y);

while(1);
}
sliders_alpha



Joined: 03 Mar 2008
Posts: 55

View user's profile Send private message

PostPosted: Mon Mar 03, 2008 1:32 pm     Reply with quote

wow that huge O_O.

and i need to do more complex calcul than that.

thing like

b*(-(VARADC-9936)/(VARADC-5))^(a)

a,b are float
varadc is an int

i will need an entire µC just to do it and then send the result to an other µC

and

i was looking around and i found this :

Quote:
set_tris_x(0x0F)


0x0F = %00001111

X0 to X3 are now input
X4 to X7 are now output

but now, what can i do to pass X6 to input without changing the others?
_________________
yup, i know, i don't speak english very well

CCS V4.057
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 03, 2008 2:51 pm     Reply with quote

Download the CCS manual and look at the list of built-in functions
on page 141 in the Acrobat reader:
http://www.ccsinfo.com/downloads/CReferenceManual.pdf
Notice the Output_Float() function. Read the section on it.
sliders_alpha



Joined: 03 Mar 2008
Posts: 55

View user's profile Send private message

PostPosted: Mon Mar 03, 2008 3:30 pm     Reply with quote

THANKS ;)

so with OUTPUT_DRIVE(PIN_XY) i put the XY pin in output mode and with
OUTPUT_FLOAT(PIN_XY) i put the XY pin in input mode.

now let's code.
_________________
yup, i know, i don't speak english very well

CCS V4.057
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