// blinkled.c // // simple minimal program that blinks a LED // ------------------------------------------------ // configuration // change these if you're wiring the LED to a pin other than RB1 #define LED_TRIS TRISBbits.TRISB1 #define LED_PIN PORTBbits.RB1 // ------------------------------------------------ // this #include pulls in the correct processor-specific registers // definition file #include "pic18fregs.h" #pragma stack 0x200,64 code char at __CONFIG1H conf1 = 0x22; // Select HS OSC code char at __CONFIG4L conf2 = 0x81; // Disable LVP code char at __CONFIG2H conf3 = 0x0E; // DIsable WDT // ------------------------------------------------ // a simple delay function void delay_ms(long ms) { long i; while (ms--) for (i=0; i < 330; i++) ; } // -------------------------------------------------- // and our main entry point void main() { // set pin to output LED_TRIS = 0; // sit in an endless loop blinking the led for (;;) { LED_PIN = 0; delay_ms(250); LED_PIN = 1; delay_ms(250); } }