Hello,
I am not entirely sure of what you are attempting to achieve. Assuming a single 7-segment display digit is connected to
Port B, simply writing the lower 8 bits of the 10-bit ADC reading is unlikely to be meaningul. With this setup, at best you
might display a single (hexadecimal) digit, based on the upper 4-bits of the 8-bit ADC result.
I can also see a couple of issues related to the ADC. Firstly, since the result you are expecting is a single byte, the ADC
should set for 8-bit operation, rather than 10-bit, as you appear to have. Secondly, you do not wait until each conversion
is complete before attempting to read the result.
READ_ADC_HEX:
brclr ADCSC1_COCO,ADCSC1,* ; Wait for conversion complete
lda ADCRL ; Will also clear COCO flag
nsa ; Get high nybble value
and #$0F
tax
clrh
lda NUMTAB,x ; Lookup table for 7-seg digit (0-9, A-F)
sta PTBD
rts
NUMTAB: ; Lookup table for 7-seg digit
dc.b $C0,$F9,$A4,$B0
dc.b ....
etc.
With continuous conversion mode, new conversions will be completed very rapidly (within a few microseconds), and the
display of a rapidly changing value would possibly be "blurred". An alternative might be to manually start each conversion,
at a rate determined by a timing process, perhaps about five times per second.
I also note that you have defined the variable ADCSample, intended to be within RAM. However, the is preceded by the
ORG $F500 directive, which is outside of RAM boundaries.
Regards,
Mac
Message Edited by bigmac on
2008-02-05 08:47 PM