hi there
here is what im trying to do:
a simple program that is acivated from a simple switch on an input pin on RA7 on the PIC, then the pic outputs a set number of pulses on anuther output pin in my case RA0. then when it has done this it outputs a simple finish pulse on RA1 pin.
Program:
here is my program to date, i have it working but im alittle lost on putting a simple count down or up loop into it so i can set it to putput for a set number of pulses as such.
any help would be grate
program is as follows
once again thanks 8)Code:;indexer program - pules's to index with start and finish pules LIST p=16F628A ;tell assembler what chip we are using include "P16F628A.inc" ;include the defaults for the chip __config 0x3F18 ;sets the configuration settings (oscillator type etc.) ;defines PULPORT Equ PORTA ;set constant PULPORT = 'PORTA' TRIPORT Equ PORTA ;set constant TRIPORT = 'PORTA' PORT Equ TRISA ;set constant for TRIS register TRIG1 Equ 7 PULSE Equ 0 FIN Equ 1 ;end defines cblock 0x20 ;start of general purpose registers count1 ;used in delay routine counta ;used in delay routine countb ;used in delay routine count2 endc org 0x0000 ;org sets the origin, 0x0000 for the 16F628, ;this is where the program starts running movlw 0x07 movwf CMCON ;turn comparators off (make it like a 16F84) bsf STATUS, RP0 ;select bank 1 movlw b'10000000' ;set PortA 7 input rest outputs movwf PORT ;set portA bcf STATUS, RP0 ;select bank 0 clrf PULPORT ;set all outputs low ;main program loop btfss TRIPORT, TRIG1 call TRIG ;call goto loop ;loops TRIG ; movlw d'10' ;pules output for steps ;lp movwf count2 bsf PULPORT, PULSE ;output 1 for pulse RA0 call delay ;call delay bcf PULPORT, PULSE ;turn off RA0 call delay ; decfsz count2, f ; goto lp bsf PULPORT, FIN ;turn on RA1 for finish pulse call delay ;call delay bcf PULPORT, FIN ;turn off RA1 for Finihs retlw 0x00 delay movlw d'150' ;delay 250 ms (4 MHz clock) movwf count1 d1 movlw 0xC7 ;delay 1mS movwf counta movlw 0x01 movwf countb Delay_0 decfsz counta, f goto $+2 decfsz countb, f goto Delay_0 decfsz count1, f goto d1 retlw 0x00 end

Reply With Quote