; CC5X Version 3.1I, Copyright (c) B Knudsen Data ; C compiler for the PICmicro family ; ************ 21. Jan 2004 9:09 ************* processor 12F629 radix DEC Carry EQU 0 Zero_ EQU 2 RP0 EQU 5 GPIO EQU 0x05 TRISIO EQU 0x85 CM0 EQU 0 CM1 EQU 1 CM2 EQU 2 x EQU 0x20 y EQU 0x22 GOTO main ; FILE D:\Pics\code\12F629\Blink\Blink.c ;/* ; 02/05/03 ; Copyright Spark Fun Electronics© 2003 ; ; Blink on PIC12F629 ; ; Flashes all pins on PIC - 4MHz operations ; ;*/ ; ;#include "d:\Pics\c\12F629.h" // device dependent definitions ; ;#pragma config |= 0x0184 ;//Watch dog off, Power Up Timer on, Code Protect off, MCLR pin disabled - used as general IO ;//Internal 4MHz Osc with pin used at general IO ;//To change the config word for your desired setup, start ICProg and set options (Check boxes, etc). ;//Then change the above 0x0184 to the 'Config Word: xxxxh' shown in the ICProg screen. ; ;void delay_ms(uns16); ; ;//Start main - this is the very first stuff the PIC will run ;void main() ;{ main ; GPIO = 0b.1111.1111; MOVLW .255 BCF 0x03,RP0 MOVWF GPIO ; TRISIO = 0b.0000.0000; //0 = Output, 1 = Input BSF 0x03,RP0 CLRF TRISIO ; ; //The analog and compare modules are turned on by default ; CM2 = 1; CM1 = 1; CM0 = 1;//These turn the input pins back to digital I/O BCF 0x03,RP0 BSF 0x19,CM2 BSF 0x19,CM1 BSF 0x19,CM0 ; //ANSEL = 0; //Turn off ADC on the 12F675 - All pins digital ; ; //Classic while loop, loops forever ; while(1) ; { ; ; //GPIO port to low ; GPIO = 0x00; m001 CLRF GPIO ; delay_ms(1000); MOVLW .232 MOVWF x MOVLW .3 MOVWF x+1 CALL delay_ms ; ; //GPIO port to high ; GPIO = 0xFF; MOVLW .255 MOVWF GPIO ; delay_ms(1000); MOVLW .232 MOVWF x MOVLW .3 MOVWF x+1 CALL delay_ms ; ; } GOTO m001 ; ; ;} //End Main ; ;//General short delay ;void delay_ms(uns16 x) ;{ delay_ms ; uns8 y; ; for ( ; x > 0 ; x--) m002 MOVF x,W IORWF x+1,W BTFSC 0x03,Zero_ GOTO m005 ; for ( y = 0 ; y < 108 ; y++); CLRF y m003 MOVLW .108 SUBWF y,W BTFSC 0x03,Carry GOTO m004 INCF y,1 GOTO m003 m004 DECF x,1 INCF x,W BTFSC 0x03,Zero_ DECF x+1,1 GOTO m002 m005 RETURN ORG 0x2007 DATA 0184H END ; *** KEY INFO *** ; 0x0018 17 word(s) 0 % : delay_ms ; 0x0001 23 word(s) 1 % : main ; RAM usage: 3 bytes (3 local), 61 bytes free ; Maximum call level: 1 ; Total of 41 code words (4 %)