//Program to flash LEDs //Written for PIC12F683 to be compiled with the CC5X compiler //Clock frequency not changed from 4MHz default //Copyright David Theunissen 2007 www.flyelectric.ukgateway.net //PREPROCESSOR section #include "12F683.H" //PIC chip file (don't also specify in cmd prompt) #include "delay_ms.h" //Delay function used below //#include files must be in same folder as cc5x.exe if no path #pragma config = 0b.0.1100.0100 //Brown-out Detect disabled (0) //Code Protect off (1) //MCLR set to 'Internal' (1) (LEDs don't flash with other setting) //Powerup timer enabled (0) //Watchdog timer disabled (0) //Oscillator set to INTRCIO (100) //VARIABLES section #define LED0 GPIO.0 //Labels for General Purpose ports #define LED2 GPIO.2 //FUNCTIONS section void main() { TRISIO = 0b.010; //Sets GP0 and GP2 to be Outputs //Can also use TRISIO0 = 0; or TRISIO.0 = 0; (for GP0) ANS0 = 0; //Set ADC port AN0 and AN2 to digital (not enabled) ANS2 = 0; //Can also use ANSEL = 0b.010; (does both) CMCON0 = 0b.111; //Switches all 3 comparator ports off (= all digital) while (1) { LED0 = 0; //Switch specified LED off (0) / on (1) LED2 = 0; delay_ms(250); //Invokes delay function (eg: 500ms = 0.5 second) LED0 = 1; delay_ms(250); LED0 = 0; delay_ms(250); LED2 = 1; delay_ms(1000); } }