HELP!!!!!!!! switching on an led with 'c'

Started by shaunundergrad October 18, 2003
hi guys,

i have a reasonable understanding of assembly and a reasonable
understanding of 'c', however i have never used the two together, we
have a lab session in couple of weeks where we have to switch on a
led using 'c'(then more complicated things straight after). i
understand that you have to use a dedicated compiler, our problem is
we don't know how to address the ports, to be honest we don't have a
clue. would somebody please send us a very simple program switching
on a led so we can work it from there, we don't want to plagurise
just have a starting point. also does anybody know where i can get a
free compiler as i can't afford to pay some of the prices i have
seen.the pic we use is the 18fl452.

best regards

shaun




Is that the 18f452? Are you using Microchip's MCC18 compiler? If so, do something like this to turn on an led on rb0

#include p18f452.h // check the name of the processor include file.
// I think that's it.

TRISBbits.TRISB0=0; // Clear the tris bit so pin is output
LATBbits.LATB0=1; // Drive pin high (turn on led)
LATBbits.LATB0=0; // Drive pin low, turning pin off. Note that the 18f series has the LATA, LATB, etc registers. These are the output port latches. By doing bit set and reset operations on these instead of on PORTA, PORTB, etc., you avoid the read-modify-write problems where the read of the rmw reads the port lines instead of the output latch.

Good luck!

Harold FCC Rules Online at http://www.hallikainen.com
seen.the pic we use is the 18fl452.

best regards

shaun
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

">http://docs.yahoo.com/info/terms/ ________________________________________________________________
The best thing to hit the internet in years - Juno SpeedBand!
Surf the web up to FIVE TIMES FASTER!
Only $14.95/ month - visit www.juno.com to sign up today!