sbgkp
Newbie level 2
Can someone convert this code to sute into PIC10F200 ?
WAILING SIREN
Code is based on a system cycle clock of 4 MHz. If used on a system with a higher clock frequency, the timing will need to be adjusted accordingly to produce the required output frequencies.
************************************************************************************
;starting at 480Hz generate repeated sequences of 20 cycles all at the same frequency, then increase the frequency in 120 small steps and generate more cycles. When all completed, repeat the process whilst reducing the frequency at each step. Estimated time to complete a full sequence is 5 seconds
WAILING SIREN
Code is based on a system cycle clock of 4 MHz. If used on a system with a higher clock frequency, the timing will need to be adjusted accordingly to produce the required output frequencies.
************************************************************************************
;starting at 480Hz generate repeated sequences of 20 cycles all at the same frequency, then increase the frequency in 120 small steps and generate more cycles. When all completed, repeat the process whilst reducing the frequency at each step. Estimated time to complete a full sequence is 5 seconds
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 ;Initialisation of registers WAIL movlw d'180' ;Starting value for timing loop counter movwf CYCLETIME ;stores the value for reload each half cycle movlw d'120' ;number of frequency steps per burst movwf REPEATS RE_RISE movlw d'20' ;number of cycles of same frequency movwf CYCLES call TONEBURST ;generate a burst of tone at fixed frequency decf CYCLETIME,f ;increase the frequency for the next tone burst decfsz REPEATS,f ;one less frequency step to do goto RE_RISE ;continue, starting another burst at the new frequency ;until all finished ;A full sequence of 20 cycles in each of 120 frequency steps has now been completed ;now repeat the entire sequence as asbove but in steps of reducing frequency. ;Initialisation of registers FALL movlw d'120' ;number of frequency steps per burst movwf REPEATS RE_FALL movlw d'20' ;number of cycles of same frequency movwf CYCLES incf CYCLETIME,f ;increase the frequency for the next tone burst decfsz REPEATS,f ;one less frequency step to do goto RE_FALL ;continue, starting another burst at the new frequency, ;until all finished ;one full rise and fall sequence completed, so go back do it all over again goto WAIL ;back to the start ;TONEBURST subroutine ; generates a sequence of 20 cycles all at the same frequency TONEBURST bsf TONEOUT ;set output I/O bit call DELAY ;wait for the end of the output half cycle nop nop ;waste some more time to balance the on and off times bcf TONEOUT ;outpot low half cycle call DELAY decfsz CYCLES,f ;1 less cycle out of 20 goto TONEBURST ;generate some more cycles at the same frequency return ; return to make adjustments ;DELAY SUBROUTINE ;generates a time delay appropriate to the half cycle period of the output waveform ;being generated DELAY movwf CYCLETIME ;initialisation value for the time delay movwf DELAY_CTR ;load it into the decrementing counter DELAYLOOP nop nop ;waste some time decfsz DELAY_CTR,f ;less time remains now goto DELAYLOOP ;continue looping until all done return ;Time is up, so quit
Last edited by a moderator: