; CC5X Version 3.1I, Copyright (c) B Knudsen Data ; C compiler for the PICmicro family ; ************ 27. Oct 2003 18:10 ************* processor 16F84A radix DEC PORTA EQU 0x05 TRISA EQU 0x85 PORTB EQU 0x06 TRISB EQU 0x86 Carry EQU 0 Zero_ EQU 2 RP0 EQU 5 x EQU 0x0C y EQU 0x0E z EQU 0x0F GOTO main ; FILE D:\Pics\code\16F84A\Blink\Blink.c ;/* ; ; 6/24/03 ; Copyright Spark Fun Electronics 2003© ; ; Classic Blinking Test Routine for the 18 Pin PIC16F84A ; ; Flashes all pins on PIC - 20MHz operations ; ;*/ ; ;#include "d:\Pics\c\16F84A.h" // device dependent definitions ; ;//#pragma config WDTE=off, FOSC=HS ;#pragma config |= 0x3FF2 //HS Oscillator, Code Protect Off ; ;void delay_ms(uns16); ; ;void main() ;{ main ; ; PORTA = 0b.0000.0000; BCF 0x03,RP0 CLRF PORTA ; TRISA = 0b.0000.0000; //0 = Output, 1 = Input BSF 0x03,RP0 CLRF TRISA ; ; PORTB = 0b.0000.0000; BCF 0x03,RP0 CLRF PORTB ; TRISB = 0b.0000.0000; //0 = Output, 1 = Input BSF 0x03,RP0 CLRF TRISB ; ; while (1) ; { ; ; PORTA = 0xFF; BCF 0x03,RP0 m001 MOVLW .255 MOVWF PORTA ; PORTB = 0xFF; MOVWF PORTB ; delay_ms(1000); MOVLW .232 MOVWF x MOVLW .3 MOVWF x+1 CALL delay_ms ; ; PORTA = 0x00; CLRF PORTA ; PORTB = 0x00; CLRF PORTB ; delay_ms(1000); MOVLW .232 MOVWF x MOVLW .3 MOVWF x+1 CALL delay_ms ; } GOTO m001 ; ;} ; ;//General short delay ;void delay_ms(uns16 x) ;{ delay_ms ; uns8 y, z; ; for ( ; x > 0 ; x--) m002 MOVF x,W IORWF x+1,W BTFSC 0x03,Zero_ GOTO m007 ; for ( y = 0 ; y < 4 ; y++) CLRF y m003 MOVLW .4 SUBWF y,W BTFSC 0x03,Carry GOTO m006 ; for ( z = 0 ; z < 176 ; z++); CLRF z m004 MOVLW .176 SUBWF z,W BTFSC 0x03,Carry GOTO m005 INCF z,1 GOTO m004 m005 INCF y,1 GOTO m003 m006 DECF x,1 INCF x,W BTFSC 0x03,Zero_ DECF x+1,1 GOTO m002 ;} m007 RETURN ORG 0x2007 DATA 3FF2H END ; *** KEY INFO *** ; 0x001A 24 word(s) 1 % : delay_ms ; 0x0001 25 word(s) 1 % : main ; RAM usage: 4 bytes (4 local), 64 bytes free ; Maximum call level: 1 ; Total of 50 code words (4 %)