; values in CAPS, self defined pointers and labels not, radix dec processor pic16f628a list n=0,st=off,mm=on #include "p16f628a.inc" ; initialize some preprocessor symbols CONFIG_WORD = 0x3fff OPTION_REG_CONFIG = 0 ; set config word CONFIG_WORD &= _CP_OFF & _DATA_CP_OFF ; turn all code protection off CONFIG_WORD &= _LVP_OFF ; disable Low Voltage Programming CONFIG_WORD &= _BODEN_OFF ; disable Brown-out Detect Reset CONFIG_WORD &= _MCLRE_OFF ; disable reset pin CONFIG_WORD &= _PWRTE_ON ; enable power on timer CONFIG_WORD &= _WDT_OFF ; disable Watchdog Timer ;CONFIG_WORD &= _INTRC_OSC_NOCLKOUT ; enable internal oscillator CONFIG_WORD &= _HS_OSC ; enable external 20MHz crystal __config CONFIG_WORD ; USART buffers in bank 0 buf0 equ 0x20 buf1 equ 0x30 buf_size equ 0x40 ; used by receiver buf_len equ 0x41 ; used during processing address equ 0x42 ; this chip's address FSR_tmp equ 0x43 usart_state equ 0x44 usart_tmp0 equ 0x45 usart_tmp1 equ 0x46 profile_index equ 0x47 dim0_ctr equ 0x60 dim1_ctr equ 0x61 dim2_ctr equ 0x62 dim3_ctr equ 0x63 ;dim0_pres_ctr equ 0x68 ;dim1_pres_ctr equ 0x69 ;dim2_pres_ctr equ 0x6A ;dim3_pres_ctr equ 0x6B ; file registers in bank 0, 1, 2, 3 dim0_val equ 0x70 dim1_val equ 0x71 dim2_val equ 0x72 dim3_val equ 0x73 dim0_inc equ 0x74 dim1_inc equ 0x75 dim2_inc equ 0x76 dim3_inc equ 0x77 ;dim0_pres_val equ 0x78 ;dim1_pres_val equ 0x79 ;dim2_pres_val equ 0x7A ;dim3_pres_val equ 0x7B dim0_mode equ 0x7C dim1_mode equ 0x7D dim2_mode equ 0x7E dim3_mode equ 0x7F ; some useful definitions RA0 equ 0 ; RA0 is bit zero in PORTA RA1 equ 1 ; etc RA2 equ 2 RA3 equ 3 RB4 equ 4 RB5 equ 5 ; pin assignments ; RA0 dim0 ; RA1 dim1 ; RA2 dim2 ; RA3 dim3 ; RA4 NOT CONNECTED ; RA5 ICSP programming voltage ; RA6 oscillator crystal ; RA7 oscillator crystal ; RB0 zero crossing interrupt on falling edge ; RB1 asynchronous serial receive ; RB2 asynchronous serial transmit (unused for now) ; RB3 NOT CONNECTED ; RB4 relais0 ; RB5 relais1 ; RB6 ICSP PCG ; RB7 ICPS PCD org 0x0000 reset_vector ; the chip starts executing our code here movlw 7<