; eBASIC PIC16 Code Generator ; Copyright(c) 2004, Compubotics LLC ; www.Compubotics.com ORG 0x0 ; File: blinky.bas ; ' Blinky example ; ' Compubotics eBASIC Compiler ; ' ; ' This example blinks an LED attached to PORTB.0 (PB1 on the RC40) ; ' using the native pin functionality ; ' Unlike the HIGH and LOW Stamp commands, this method gives us access ; ' to all pins on the device. ; ' ; ' For this version of BLink, we're using the RC40, so we have included ; ' the RC40.INC file that contains the various port definitions. The ; ' #clock and #device entries are also in this include file. ; ; #include "rc40.inc" ; #debug OFF ; ; Forever con 1 ; PinHigh con 1 ; PinLow con 0 ; PinOut con 0 ; ; Main: nop clrf 0xa goto _startup ORG 0x4 retfie _startup: movlw 0x83 bsf 0x3,5 movwf 0x81 bcf 0xb,5 movlw 0x39 bcf 0x3,5 movwf 0x10 movlw 0x60 movwf 0x78 goto Main ; ; ' set PB1 to output ; TRISPB1 = PinOut Main: bsf 0x3,5 bcf 0x86,0 ; ; while (FOREVER) ; PB1 = PinHigh _j000: bcf 0x3,5 bsf 0x6,0 ; pause 200 movlw 0xc8 movwf 0x70 movlw 0x0 movwf 0x71 call _pause ; PB1 = PinLow bcf 0x3,5 bcf 0x3,6 bcf 0x6,0 ; pause 200 movlw 0xc8 movwf 0x70 movlw 0x0 movwf 0x71 call _pause ; wend goto _j000 ; ; ; END _j001: sleep goto $-1 _dec16: decf 0x70,1 incfsz 0x70,0 incf 0x71,1 decf 0x71,1 movf 0x70,0 iorwf 0x71,0 return _pause: bcf 0xb,2 btfss 0xb,2 goto $-1 call _dec16 btfss 0x3,2 goto _pause return END ; end of code generation