> Hi to all engineers,
>
> I wrote simple led test code for microchip demo board2
> it works but when I move main () function to top it generates
> an error why?
> Any help will appreciate. Hitech support said I didn't
> Define port_init () function but I do not get it.
>
>
> Andre
>
>
>
>
>
> /* simple led right,left move C code for Hi-Tech compiler*/
> #include <pic18.h>
> #include "delay.c"
> #define PORTBIT(adr, bit) ((unsigned)(&adr)*8+(bit))
> static bit led1 @ PORTBIT(PORTB, 0);
> static bit led8 @ PORTBIT(PORTB, 7);
>
> // led right,left test funtion
> void ledrl(void){
> int c; // setup c for count
> led1=1; // make RB0 on
> DelayBigMs(20); // delay
> for(c=7;c!=0;c--){ // setup counter to count 7 times
> PORTB <<= 1 ; // shift left since c!=0 it will exit when c==0
> DelayBigMs(20);} // delay led8=1; DelayBigMs(20);
> for(c=7;c!=0;c--){ PORTB >>= 1; DelayBigMs(20);} }
>
> // Port Init
> void port_init(void){
> TRISB=0; // set portb output
> TRISA=1; // set portc all input
> PORTB=0; // make sure all leds off
> }
>
> // main program
> void main(void)
> {
> port_init(); // setup port
> ledrl(); // call led funtion
> }
>
> --
>
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
> email
listserv
KILLspammitvma.mit.edu with SET PICList DIGEST in the body