// -*- tab-width: 4 -*- // LED Blinker for HOODMICRO // // Copyright (c) 2005, K9spud LLC. // http://www.k9spud.com/hoodmicro/ // // Compile from command line: // picl -12F629 -Zg blink.c // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include // Configuration word set to: // - internal oscillator (INTIO) // - watch dog timer disabled (WDTDIS) // - power up timer enabled (PWRTEN) // See PIC12F6X.H in the HI-TECH PICC include folder for all options. __CONFIG(INTIO & WDTDIS & PWRTEN); #define bitset(var, bit) ((var) |= 1 << (bit)) #define bitclr(var, bit) ((var) &= ~(1 << (bit))) #define LED_PIN 4 void main(void) { unsigned int i; INTCON = 0; // disable interrupts TRISIO = ~(1 << LED_PIN); // configure all pins as inputs, except the LED_PIN OSCCAL = _READ_OSCCAL_DATA(); // restore oscillator calibration for(;;) { bitset(GPIO, LED_PIN); // turn the LED on for(i = 0; i < 10000; ++i) { // do nothing, busy wait loop } bitclr(GPIO, LED_PIN); // turn the LED off for(i = 0; i < 10000; ++i) { // do nothing, busy wait loop } } }