View previous topic :: View next topic |
Author |
Message |
sliders_alpha
Joined: 03 Mar 2008 Posts: 55
|
Looking for basic tutorial |
Posted: Mon Mar 03, 2008 4:23 am |
|
|
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
|
|
Posted: Mon Mar 03, 2008 12:28 pm |
|
|
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
|
|
Posted: Mon Mar 03, 2008 1:32 pm |
|
|
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 :
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
|
|
|
sliders_alpha
Joined: 03 Mar 2008 Posts: 55
|
|
Posted: Mon Mar 03, 2008 3:30 pm |
|
|
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 |
|
|
|