; bw 20 aug 2000 ; derived from wiggle5.asm ; but no prescaler, so we get higher resolution ; pin 18 toggles once every second LIST P=16F84, R=DEC INCLUDE "P16f84.inc" __CONFIG _CP_OFF & _XT_OSC & _PWRTE_ON & _WDT_OFF led01 equ 2 ; pin 1 of chip ( RA2) led18 equ 1 ; pin 18 of chip ( RA1) SAVE_W equ 0x0C SAVE_STATUS equ 0x0D ; crystal is 3.546864 MHZ itick1 equ 0x20 ; ticks every 289 uS, wraps every 256 ticks itick2 equ 0x21 ; ticks every 289 uS, wraps at 173 (50 mS) itick3 equ 0x22 ; ticks every 50 mS, wraps at 20 (1 S) ims50 equ 0x23 ; ticks every 50 mS, wraps at 256 isec equ 0x24 ; ticks every S, wraps at 256 ;imin equ 0x25 ORG 0 GOTO Start org 4 goto ticktock org 0x50 Start CLRF STATUS CLRF PORTA CLRF PORTB BSF STATUS, RP0 MOVLW 0x00 ; all porta pins are outputs MOVWF TRISA MOVLW 0xD0 ; rb7, rb6, rb4 are inputs MOVWF TRISB BCF STATUS, RP0 BSF STATUS, RP0 MOVLW 8 ; no prescaler for timer movwf OPTION_REG BCF STATUS, RP0 clrf itick1 clrf itick2 clrf itick3 clrf ims50 clrf isec clrf TMR0 clrf INTCON bcf INTCON, T0IF ; clear timer int (if any) bsf INTCON, T0IE ; enable timer int bsf INTCON, GIE ; enable global ints Loop BSF PORTA,led01 ; wiggle pin 1 of chip BCF PORTA,led01 GOTO Loop ticktock movwf SAVE_W ; save context swapf STATUS, w movwf SAVE_STATUS CLRF STATUS ; make sure we are in bank 0 incf itick1, 1 ; highest resolution tick is abt 289 uS incf itick2, 1 movlw 173 ; 50mS at 3.547 MHZ subwf itick2,w bnc idone clrf itick2 incf ims50, 1 incf itick3, 1 movlw 20 ; 20*50=1000 = 1Sec subwf itick3,w bnc idone clrf itick3 incf isec, 1 btfsc isec, 0 goto isetled bcf PORTA,led18 goto idone isetled bsf PORTA,led18 idone swapf SAVE_STATUS, w ; restore context movwf STATUS swapf SAVE_W, f swapf SAVE_W, w bcf INTCON, T0IF ; clear int (doesnt mess up status reg) retfie END