05.09.2013 Views

2.3 Relaxatie-oscillator

2.3 Relaxatie-oscillator

2.3 Relaxatie-oscillator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

setb TR0 ;1 timer 0 runs, but enough time till int. comes<br />

jb np_flag,ti_nnow ;2 if main is processing data, skip summing<br />

mov tmp_A,A<br />

mov tmp_C,C<br />

mov A,OP_3 ;now enough time to perform 24 bits addition<br />

add A,tmp_TL0 ;LSB<br />

mov OP_3,A<br />

mov A,OP_2<br />

addc A,tmp_TH0 ;MSB<br />

mov OP_2,A<br />

jnc ti_fmty ;if there is no carry, routine is ready<br />

inc OP_1 ;I say: 24 bits is really enough!<br />

ti_fmty: djnz R3,ti_reta ;decrease counter for #num_per, jmp if not zero<br />

setb np_flag ;flag to tell main interrupt routine is ready<br />

ti_reta: mov C,tmp_C<br />

mov A,tmp_A<br />

ti_nnow: reti<br />

;**** part I **** wvmem:=lo, vldsns no change ****<br />

;put sensctrl and flag wvmem in low state, disable EX1 (no _int1), set timer0<br />

ti_dolo: clr wvmem ;1 flag of sensctrl<br />

clr sensctrl ;1 sensctrl goes lo<br />

mov TH0,lo_TH0 ;2 timer 0 hi-byte<br />

mov TL0,lo_TL0 ;2 timer 0 lo-byte<br />

setb TR0 ;1 timer 0 runs<br />

clr EX1 ;1 no _int1 allowed during lo state<br />

reti<br />

;*******************************************************************************<br />

;* sens_stamp -> (from EXTI1) TH0, TL0 *<br />

;* interrupt from _int1 occurred, so there’s some work to do. Sensor produced *<br />

;* an transistion from hi to lo, so it’s position where that happened, rela- *<br />

;* ted to the pos. of timer0, generating a control signal, must be stamped. *<br />

;* (OP_0..3) * (R2,R3) *<br />

;* *<br />

;* Performs a multiply between a 32 and a 16 bit integer *<br />

;* *<br />

;*

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!