Getting Started with RS08, Rev. 1
Emulated ADC Application Example
Freescale Semiconductor26
bset ACMP1SC_ACF, ACMP1SC ;Clear ACMP Flag
clr ACMP1SC ;disable ACMP
mov #(mMTIM1SC_TSTP|mMTIM1SC_TRST), MTIM1SC ;mask int and clear flag
rts
NoReading:
mov #$FF, SensorReading ;Biggest Number
clr ACMP1SC ;disable ACMP
mov #(mMTIM1SC_TSTP|mMTIM1SC_TRST), MTIM1SC ;mask int and clear flag
rts
d) In TableLookup subroutine the two most significant bits (MSB) of the variable SensorReading
are extracted and added to the page number that holds the lookup table. The corresponding
lookup table content is mapped to the 64-byte paging window, $00C0 to $00FF. Then the six
least significant bits (LSB) of the variable SensorReading is used as an index to read out the
upper memory content directly from the paging window.
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; 8bit Table Lookup
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TableLookup:
lda SensorReading ;
rola ;Extract 2 MSB
rola ;
rola ;
and #$03 ;Mask all other bits
add #(TableStart>>6) ;Add to Lookup table page
sta PAGESEL ;High page
lda SensorReading ;
and #$3F ;Extract 6 LSB
add #$c0 ;Index to paging window
tax ;
lda ,x ;Read upper memory
sta ADCOut ;Store lookup table content
mov #(HREG), PAGESEL ;Return to register page
rts ;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; ADC Lookup Table - RC charging profile
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
org TableStart
dc.b 0, 5, 10, 14, 18, 23, 27, 31, 35, 39, 43, 47, 50, 54, 58, 61
dc.b 65, 68, 71, 75, 78, 81, 84, 87, 90, 93, 96, 99,102,105,107,110
dc.b 113,115,118,120,123,125,127,130,132,134,136,138,141,143,145,147
dc.b 149,150,152,154,156,158,160,161,163,165,166,168,169,171,173,174
dc.b 175,177,178,180,181,182,184,185,186,188,189,190,191,192,193,195
dc.b 196,197,198,199,200,201,202,203,204,205,206,206,207,208,209,210
dc.b 211,211,212,213,214,215,215,216,217,217,218,219,219,220,221,221
dc.b 222,223,223,224,224,225,225,226,226,227,228,228,228,229,229,230
dc.b 230,231,231,232,232,233,233,233,234,234,235,235,235,236,236,236
dc.b 237,237,237,238,238,238,239,239,239,240,240,240,240,241,241,241
dc.b 241,242,242,242,242,243,243,243,243,244,244,244,244,244,245,245
dc.b 245,245,245,246,246,246,246,246,246,247,247,247,247,247,247,247
dc.b 248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249
dc.b 250,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251
dc.b 251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252
dc.b 252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,253