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.

ajmp sendmd2<br />

ajmp waittx<br />

ajmp caseovr<br />

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

;* cptfull -> np_flag, OP_0..3, R2, R3 *<br />

;* from interrupt proces there might be enough captured date, to proces *<br />

;* further here: calculate average. When finished next task *<br />

;* OP_0..3 *<br />

;* The summing must be converted to a proper midi value (0..127) *<br />

;* midival is only stored if it is different from calculated value in acc. *<br />

;* If they’re equal, the dispatcher starts from beginning, so byte will not *<br />

;* be transmitted. *<br />

;* (OP_2..3) *<br />

;* 256 multiply: (OP_2..3) -> (OP_1..2) *<br />

;* division: (OP_0..3)/(wndwTH/L0) (creates value 0..255) *<br />

;* linearisation: array[0..255] -> 0..127 *<br />

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

convert: clr C ;substr. ffffh - <br />

mov A,#0ffh<br />

subb A,OP_3 ;LSB<br />

mov OP_3,A<br />

mov A,#0ffh ;MSB<br />

subb A,OP_2<br />

mov OP_1,A ;store result in OP_1..2<br />

mov OP_2,OP_3 ;perform 256*multiply<br />

mov OP_3,#0<br />

mov R2,wndwTH0<br />

mov R3,wndwTL0<br />

acall Div_16 ;result in OP_0..3 (0..255)<br />

mov DPTR,#lintbl ;in lintbl is a table to linearizate output<br />

mov A,OP_3 ;index to accumulator<br />

movc A,@A+DPTR ;move array value to accumulator<br />

cjne A,midival,newmdi ;continue only if value is different<br />

ajmp caseovr ;in the beginning there was...<br />

newmdi: mov midival,A ;new value, so save value in midival<br />

ajmp inccase<br />

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

;* sendmd1 -> *<br />

;* transmits first control byte midictrl *<br />

;* *<br />

;* transmits second midi value byte *<br />

;* *<br />

;* waits till byte is transmitted *<br />

;* *<br />

54

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

Saved successfully!

Ooh no, something went wrong!