2.3 Relaxatie-oscillator
2.3 Relaxatie-oscillator
2.3 Relaxatie-oscillator
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
; EXTI1->(sens_stamp): 0013h (interrupt vector for saving pos. of timer0)<br />
; (jmps to sens_stamp)<br />
; TIMER1 001bh (interrupt vector for overflow in timer1)<br />
; (process: carry timer overflow to OP_1)<br />
;************************* functions ***********************************<br />
; main: (main program starts here)<br />
; initsys: (initializes system: ports, interrupts, variables)<br />
; sett0_cnt: (initializes timer0 for counting)<br />
; sett1_cnt: (initializes timer1 for counting)<br />
; sett1_midi: (initializes timer1 for midi)<br />
; calc_t0: (calculates setup timer values for signal)<br />
; calib: (loads prd with proper values)<br />
; freqcap: (measures frequency on _int0<br />
; wavectrl(wvmem): (processes generated waveform)<br />
; sens_stamp(tmp_TH0,tmp_TL0) (stamps position of TH0 and TL0, when sensor)<br />
; Mul_16( (OP_0..3) * (R2,R3) ) (Performs multiply between long and int)<br />
; Div_16( (OP_0..3) / (R2,R3) ) (Performs division between long and int)<br />
;************************* constants ***********************************<br />
clk equ 12000 ;system clock in kHz<br />
baud equ 31250 ;bits/s on midi output<br />
sigpw equ 35 ;pulsewidth of lo state in µsec<br />
ccpins equ 12 ;#clockcycles per instruction<br />
proc_tm equ 20 ;est. processing time, interrupt routine<br />
num_per equ 10 ;#periods to calculate average<br />
shift_wv equ 25 ;force sensor to run in phase with wave (in µsec)<br />
sens_tm equ 46 ;sensor reaction is valid during 42% of hi-wave<br />
sensctrl bit P1.0 ;output port, controls sensor<br />
sensor bit P3.2 ;input port, sensor feed back signal<br />
midictrl equ 0d0h ;coding for general aftertouch with midi<br />
;************************** variables ***********************************<br />
wvmem equ 20h.0 ;bit adres for hi or lo state of output signal<br />
vldsns equ 20h.1 ;bit adres for valid sensor measurement (1=valid)<br />
np_flag equ 20h.2 ;flag for avialability of enough data from int. routine<br />
tmp_C equ 20h.3 ;flag for temporary storing Carry<br />
tmp_A equ 43h ;register is faster than stack<br />
prd_h equ 44h ;target period MSB in timer counting rate<br />
prd_l equ 45h ;target period LSB in timer counting rate<br />
lo_TH0 equ 46h ;duration lo state MSB timer0<br />
lo_TL0 equ 47h ;duration lo state LSB timer0<br />
hi_TH0 equ 48h ;duration hi state MSB timer0<br />
hi_TL0 equ 49h ;duration hi state LSB timer0<br />
hivdTH0 equ 4ah ;duration hi state, during which sensor may respond<br />
hivdTL0 equ 4bh ;duration hi state, during which sensor may respond<br />
OP_0 equ 4ch ;Operand1 (Highest byte unsigned long)<br />
OP_1 equ 4dh ;<br />
OP_2 equ 4eh ;<br />
OP_3 equ 4fh ;<br />
;R2 ;Operand2 (Highest byte unsigned ‘long’<br />
;R3 ;functions implement uptill now only int size<br />
TMP_0 equ 50h ;Highest byte unsigned long<br />
TMP_1 equ 51h ;<br />
TMP_2 equ 52h ;<br />
TMP_3 equ 53h ;<br />
tmp_TH0 equ 54h ;memory for position of TH0<br />
tmp_TL0 equ 55h ;memory for position of TL0<br />
wndwTH0 equ 56h ;size of valid window where sensor may respond<br />
wndwTL0 equ 57h ;size of valid window where sensor may respond<br />
case equ 58h ;task dispatcher in main<br />
midival equ 59h ;pressure (0..127) into control midivalue<br />
52