Embedded PIC C programming
Embedded PIC C programming
(OP)
Hey guys, I was wondering if anyone could direct me to a site that explains, in detail, embedded C programming for PIC microcontrollers. I am trying to learn how to manipulate data on PORTS such as see if a switch has been pressed and stuff like that. It seems quite trivial and i can do it in assembly but i am a little confused. Any help would be appreciated.





RE: Embedded PIC C programming
{
Personally, I would program a PIC in C only if "tied to a horse, and dragged forty miles ... by my tongue". Perhaps you have other incentives.
}
What about the documentation that came with your C compiler? And all the stuff on the Microchip CD?
Mike Halloran
NOT speaking for
DeAngelo Marine Exhaust Inc.
Ft. Lauderdale, FL, USA
RE: Embedded PIC C programming
RE: Embedded PIC C programming
Hi Mike-
You might want to do a google search on "cc5x" and revisit
the C compilers for PICs.
It's a freebie that runs on Windoze, but aside from that
limitation, it isn't too bad.
As an evaluation example, I did a "geek-clock" with it using
my favorite mid-level pic, 16f648A.
Turns out that although there were some differences and
implementation details (some of the K&R C code didn't
compile and had to be worked around) it came up pretty
clean.
With the "freebie" package, you get a floating point math
package (although not the complete package) and can have
oddles of fun with it for no investment.
The code is surprisingly compact and with the mixed listing,
I found it to be very easy to use with the microchip
simulator.
YMMV, of course, but I think that it will be a tool that I
will keep in my toolbox.
Cheers,
Rich S.
RE: Embedded PIC C programming
I'd much rather deal with a language whose behavior can be completely described in one paragraph; FORTH. Or, no language at all, just a decent assembler that does what it's told to do.
Mike Halloran
NOT speaking for
DeAngelo Marine Exhaust Inc.
Ft. Lauderdale, FL, USA
RE: Embedded PIC C programming
Here is a read and a write to port b. write commented out.
#include <p18cxxx.h> /* for TRISB and PORTB declarations */
/*
void main (void)
{
TRISB = 0; //sets port b as all outputs
PORTB = 255; //set port b bits
}
*/
int buttons;
void main (void)
{
TRISB = 255; //sets port b as all inputs
buttons = PORTB; //read port b bits
}
RE: Embedded PIC C programming
One man's pleasure is another man's poison.
I've used the C preprocessor quite a number of times all
by itself to manipulate data and find it a blessing.
Each to his own.
Cheers,
Rich S.
RE: Embedded PIC C programming
Cheers