;********************************************************************** ; ; CN001 - test try ; ; LED flasher ..._ ..._ ; ; ; TMRpattern | TMRpattern2 ; _ _ _ _ _ _ t t|t t t t t _ _ t ; _ _ _ _ _ _/-\_/-\_/-\_/- - -\ ; left bit used first ; ; ; ; This file is a basic code template for assembly code generation * ; on the PICmicro PIC10F204. This file contains the basic code * ; building blocks to build upon. * ; * ; Refer to the MPASM User's Guide for additional information on * ; features of the assembler (Document DS33014). * ; * ; Refer to the respective PICmicro data sheet for additional * ; information on the instruction set. * ; * ; * ; * ;********************************************************************** ; * ; Filename: CN001.asm ; Date: Jan 2005 ; File Version: * ; * ; Author: Doug Rice ; Company: * ; * ; * ;********************************************************************** ; * ; Files required: * ; * ; * ; * ;********************************************************************** ; * ; Notes: * ; * ; * ; * ; * ;********************************************************************** list p=10F204 ; list directive to define processor #include ; processor specific variable definitions __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF ; '__CONFIG' directive is used to embed configuration word within .asm file. ; The lables following the directive are located in the respective .inc file. ; See respective data sheet for additional information on configuration word. cblock 0x10 RAMTRIS ; this is a baseline part so I have to create my Flag ; contains misc flags temp TMRlast TMRnew TMRcnt TMRpattern ; a bit for each change TMRpattern2 ; a bit for each change IPlast IPnew IPEvents endc ;********************************************************************** org 0xFF ; processor reset vector movlw 0x40 ;****************************** START OF CODE ********************************* org 0x00 ;movlw 0x40 ;****** REMOVE THIS LINE FOR PRODUCTION ****** movwf OSCCAL ; load the factory oscillator calibration value ;****************************************************************************** ; InitializeSFRs - Initialize Special Function Registers ; ;****************************************************************************** InitializeSFRs movlw b'00111111' ; turn on comparator movwf CMCON0 movlw b'01111000' ; turn on comparator movwf CMCON0 movlw b'01111000' ; turn on comparator,wakeup,+usescin-,cinref uses int ref. movwf CMCON0 movlw b'01110000' ; turn off comparator movwf CMCON0 movlw b'00001010' ; Outputs: LED and Triac pins movwf RAMTRIS tris GPIO clrf GPIO ; turn on LED and Triac movlw b'01000011' ; 1:32TMR0 prescaler: 1E-6 x 256 x 256, weak pullups disabled option start movlw b'1000000' movwf temp MOVLW 0x00 TRIS GPIO MOVLW 0x0F MOVWF GPIO goto main ;********************************************************************** ; remaining code goes here main MOVLW 0x00 TRIS GPIO ; ; ----___---- tmr0 ; ---___----- tmrlast ; ___-__-____ events ; Poll Timer MOVFW TMR0 MOVWF TMRnew MOVFW TMRlast XORWF TMRnew,W ANDLW 0xF0 IORWF IPEvents MOVFW TMRnew MOVWF TMRlast ; poll Inputs MOVFW GPIO MOVWF IPnew MOVFW IPlast XORWF IPnew,W ANDLW 0x0F IORWF IPEvents MOVFW IPnew MOVWF IPlast ; Test for events BTFSC IPEvents,7 GOTO IPtimerEdge BTFSC IPEvents,3 GOTO IPchange GOTO main IPtimerEdge BCF IPEvents,7 INCFSZ TMRcnt GOTO main IPtimerEdge1 ; prepare to reload pattern ; ; t t _ t t _ _ t ; /-\___/-\_____/ ; ; MOVLW b'10011011' ; _ t _ t t t t t ; _/- -\_/-\_/-\ ; ; MOVLW b'00001111' ; _ _ _ _ t t t t ; _ _ _ _/-\__/-\ ; ; MOVLW b'00001111' ; left bit used first ;MOVLW b'00001111' ; t _ t _ t t t t ; /- -\_ _/-\_/-\_ ; left bit used first ;MOVLW b'10101111' ; test pattern for zero MOVFW TMRpattern IORWF TMRpattern2,w BNZ IPtimerEdge2 ; re sync bit toggle BCF GPIO,0 ; TMRpattern | TMRpattern2 ; _ _ _ _ _ _ t t|t t t t t _ _ t ; _ _ _ _ _ _/-\_/-\_/-\_/- - -\ ; left bit used first MOVLW b'00000011' MOVWF TMRpattern MOVLW b'11111001' MOVWF TMRpattern2 IPtimerEdge2 BCF STATUS,C RLF TMRpattern2,f RLF TMRpattern,f MOVFW STATUS ANDLW 0x01 XORWF GPIO,f GOTO main IPchange BCF IPEvents,3 MOVLW 0x04 XORWF GPIO,f GOTO main END ; directive 'end of program'