http://www.r4nd0m.com/SoundAnnoyer.html
koden är skriven för p10f202 och jag har bara 12f675 och 12f629 som ligger "närmast"
behöver koden skrivas om nåt eller räcker det med att ändra INCLUDE "p10f202.inc" raden?
har inte programmerat pic eller asm innan (har en wisp628 men har aldrig kommit igång)
Kod: Markera allt
LIST R=DEC
INCLUDE "p10f202.inc"
errorlevel -302 ; Register not in bank 0 warning
__CONFIG _CP_OFF & _MCLRE_ON & _WDT_OFF
d1 EQU 0x10
d2 EQU 0x11
d3 EQU 0x12
LFSR EQU 0x13
count EQU 0x14
PAGE
org 0
nop
main:
clrf GPIO
movlw 0x0
tris GPIO
clrf LFSR
MainLoop:
call Speaker ; Gung ho!
;*** Get new LFSR
movlw 0x0B ; We will add 11 each time
addwf LFSR, f ; to the LFSR
movlw b'00001111' ; Make it 4 bit
andwf LFSR, w
movwf count ; And just use that for count variable
incf count, f ; Add a couple so they're not too
incf count, f ; close together
incf count, f
WaitLoop:
call MinDelay
decfsz count, f ; we will loop LFSR times throughj
goto WaitLoop
goto MainLoop
;***** Play speaker for .25 seconds *****
Speaker:
clrf count ; Set counter
movlw 0x0B
movwf d2
SpeakerLoop
bsf GPIO, 0 ; Turn on Speaker
movlw 0x10 ; Delay
movwf d1
Delay_0:
decfsz d1, f
goto Delay_0
bcf GPIO, 0 ; Turn speaker off
movlw 0x10 ; Delay
movwf d1
Delay_1
decfsz d1, f
goto Delay_1
decfsz count, f ; Are we done with loop yet?
goto SpeakerLoop ; no, so keep going
decfsz d2, f
goto SpeakerLoop
return ; yes, so return
;************ 1 minute delay **************
MinDelay:
movlw 0xFF
movwf d1
movlw 0xFF
movwf d2
movlw 0x83
movwf d3
Delay_2:
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_2
return
endEdit: la till källkoden
