;********************************************************************** ; 12C509 code for reading the status of a SONY camera using the * ; LANC interface (also known as Control-L). Drives different LEDs * ; to indicate the status of the camera (on/off, standby, recording) * ; * ;********************************************************************** ; * ; Filename: lanc.asm * ; Date: 2005-04-18 * ; File Version: 1.1 * ; * ; Author: Marco Scheibe * ; Company: Exit-Exit * ; * ; * ;********************************************************************** ; * ; Files required: * ; * ; * ; * ;********************************************************************** ; * ; Notes: old version of 2002-02-26 was buggy !! * ; this one should be usable for 12F509 as well since * ; Microchip does not recommend the 12C509A anymore * ; * ;********************************************************************** list p=12c509a ; list directive to define processor #include ; processor specific variable definitions __CONFIG _CP_OFF & _WDT_OFF & _MCLRE_OFF & _IntRC_OSC ; ; GP0 is LANC input ; GP1, GP2 are LED outputs ; LANC EQU 0 LED1 EQU 1 LED2 EQU 2 count EQU 0x07 nbits EQU 0x08 bytecnt EQU 0x09 recvb EQU 0x0A ;********************************************************************** ORG 0x3FF ; processor reset vector ; Internal RC calibration value is placed at location 0x3FF by Microchip ; as a movlw k, where the k is a literal value. ORG 0x000 movwf OSCCAL ; remaining code goes here _init movlw 0xD7 option ferror bcf STATUS, PA0 movlw 0xE9 tris GPIO movlw 0x00 movwf GPIO sync clrf count _sync1 btfss GPIO, LANC goto sync nop incfsz count, F goto _sync1 synced clrf bytecnt waitsb btfsc GPIO, LANC goto waitsb startb movlw 0x11 movwf count _sb1 decfsz count, F goto _sb1 btfsc GPIO, LANC goto ferror movlw 0x08 movwf nbits waitb movlw 0x20 movwf count _sb2 decfsz count, F goto _sb2 readb rrf recvb, F bcf recvb, 7 btfss GPIO, LANC bsf recvb, 7 decfsz nbits, F goto waitb waiths movlw 0x22 movwf count _sb4 decfsz count, F goto _sb4 nop rdstop btfss GPIO, LANC goto ferror incf bytecnt, F decf bytecnt, W andlw 0x07 addwf PCL, F goto _byte0 goto _byte1 goto _byte2 goto _byte3 goto _byte4 goto _byte5 goto _byte6 goto _byte7 _byte0 goto waitsb _byte1 goto waitsb _byte2 goto waitsb _byte3 goto waitsb _byte4 movlw 4 subwf recvb, W btfss STATUS, Z goto _cstby bsf GPIO, LED1 bcf GPIO, LED2 goto _endb4 _cstby movlw 0x14 subwf recvb, W btfss STATUS, Z goto _nocode bcf GPIO, LED1 bsf GPIO, LED2 goto _endb4 _nocode bcf GPIO, LED1 bcf GPIO, LED2 _endb4 goto waitsb _byte5 goto waitsb _byte6 goto waitsb _byte7 clrf bytecnt goto sync END