;**********************************************************************
; This file is a basic code template for assembly code generation *
; on the PICmicro PIC12C508A. This file contains the basic code *
; building blocks to build upon. *
; *
; If the internal RC oscillator is not implemented then the first *
; instruction after the ORG 0x000 directive is not required. *
; *
; 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. *
; *
; Template file assembled with MPLAB V3.99.18 and MPASM V2.15.06. *
; *
;**********************************************************************
; *
; Filename: xxx.asm *
; Date: *
; File Version: *
; *
; Author: *
; Company: *
; *
; *
;**********************************************************************
; *
; Files required: *
; *
; *
; *
;**********************************************************************
; *
; Notes: *
; *
; *
; *
; *
;**********************************************************************
list p=12c508a ; list directive to define processor
#include <p12c508a.inc> ; processor specific variable definitions
__CONFIG _CP_ON & _WDT_OFF & _MCLRE_ON & _LP_OSC ;external /MCLR, no wdt, 32kHz oscillator
; '__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.
#define SEC_OUT GPIO,0 ;
#define _SEC_OUT GPIO,1 ;
#define MIN_OUT GPIO,2 ;
;***** CONSTANT DEFINITIONS
OPTION_CFG EQU B'11000100' ;option register configuration: no pullups, no wakeup, internal TMR0 1:16
PORT_CFG EQU 0x00 ;port configuration, all outputs
PORT_INI EQU B'00000010' ;port initialization value, SEC_OUT low, /SEC_OUT high, MIN_OUT low
CONST_03 EQU D'77' ;constant used to generate 0.3sec delays
;***** VARIABLE DEFINITIONS
MIN EQU 0x07 ;temporary storage, counter 60 seconds
;**********************************************************************
ORG 0x1FF ; processor reset vector
; Internal RC calibration value is placed at location 0x1FF by Microchip
; as a movlw k, where the k is a literal value.
ORG 0x000 ; coding begins here
goto Main ;jump to beginning of code
ORG 0x008 ;save these locations for code changes
Main: movlw OPTION_CFG ;setup option reg
option ;
movlw PORT_INI ;initialize port
movwf GPIO ;
movlw PORT_CFG ;configure port pins
tris GPIO ;
movlw 0x01 ;initialize timer
movwf TMR0 ;
movlw D'60' ;initialize counter
movwf MIN ;
Wait_0: movf TMR0,W ;read timer
btfss STATUS,Z ;check if it rolled over
goto Wait_0 ;if not, wait
bcf MIN_OUT ;clear minute output
bsf SEC_OUT ;set SEC_OUT output
bcf _SEC_OUT ;clear the /SEC_OUT
decfsz MIN,F ;decrement minute counter
goto Wait_03 ;if not zero, go generate 0.3sec pulse
movlw D'60' ;reload counter
movwf MIN ;
bsf MIN_OUT ;set minute output
Wait_03: movlw CONST_03 ;wait here for 0.3s
subwf TMR0,W ;
btfss STATUS,C ;
goto Wait_03 ;
bcf SEC_OUT ;clear seconds output
bsf _SEC_OUT ;set complementary output
goto Wait_0 ;go back wait in the loop
;-----------------------------------------------------------------------
END ; directive 'end of program'