I am new to pic programming. I want to create a tool that produces 2 votes with the switch and I've tried to make programs and I beg you to check for errors and make suggestions for my program.....
Rich (BB code):
;Project: Siren Sound
;*************set up port******
org 0000h ;This is the start of memory for the program.
bsf 03h,5 ;Go to Bank 1
movlw b'11111' ;taruh "11111" ke W
movwf 05h ;RA1, Ra2, Ra3, Ra4, Ra5 input
bcf 03h,5 ;Go to Bank 0 - the program memory area.
bsf 03h,7 ;
movlw 00h ;
movwf 06h ;Rb1 - Rb7 ouput
bcf 03h, 7 ;
;*******pemanggilan perintah*********
btfsc 85h, 1 ;cek value di input
call siren
btfsc 85h, 2 ;cek value di input
call hee1
;if 85h = b"00001" then Siren ELSE hee1
;********sirine***************
siren movlw 80h ;Number of cycles for each tone
MOVWF 0Eh ;pindahkan isi register w ke f pada TMR1L
MOVWF 10h ;pindahkan isi register w ke f pada T1CON
movlw 50h ;Number of steps
MOVWF 0Fh ;File 0F holds the number of steps
movlw 50h ;Determines frequency
MOVWF 0Ch ;File 0C determines the frequency
repeat MOVF 0C,0 ;File 0C is moved to W
MOVWF 0D ;W is moved to file 0D for decrementing
on BSF 06h,7 ;Length of HIGH time to Piezo
DECFSZ 0D,1
GOTO on
MOVWF 0Dh ;W is moved to file 0D again
off BCF 06h,7 ;Length of LOW time to Piezo
DECFSZ 0D,1
GOTO off
DECFSZ 10h,1 ;Number of cycles for each tone
GOTO repeat
DECF 0C,1 ;HIGH and LOW is shortened -tone rises
INCF 0E,1 ;Increase the number of cycles
MOVF 0E,0 ;File 0E to W
MOVWF 10h ;W to file 10h
DECFSZ 0F,1 ;Number of steps
GOTO repeat
GOTO siren
;*******************hee haw******************
hee1 movlw 0FFh ;Number of loops
MOVWF 14h ;The loop file
hee2 movlw 0C0h ;Duration of HIGH
BSF 06h,7 ;Turn on piezo
hee3 NOP
DECFSZ 15h,1 ;Create the HIGH time
GOTO hee3
movlw 0C0h ;Duration of the LOW
MOVWF 15h ;The LOW file
BCF 06h,7 ;Turn off piezo
hee4 NOP
DECFSZ 15h,1 ;Create the LOW time
GOTO hee4
DECFSZ 14h,1 ;Decrement the loop file
GOTO hee2 ;Do more cycles
movlw 0C0h ;Number of loops
MOVWF 14h ;The loop file
haw1 MOVLW 0FFh
MOVWF 15h
BSF 06h,7 ;Turn on piezo
haw3 NOP
DECFSZ 15h,1 ;Create the LOW time
GOTO haw3
DECFSZ 14h,1 ;Decrement the loop file
GOTO haw1 ;Do more cycles
GOTO hee1
; ENDIF
END
Last edited: