ST AN672 Application note

AN672
APPLICATION NOTE
OPTIMIZING THE ST6 A/D CONVERTER ACCURACY
INTRODUCTION
When using the internal Analog to Digital Converter of the ST62 family and maximum A/D con­verter accuracy is required, it is desirable to filter out any noise present on the analog input, but also noise present on the ground and V voltage reference of the A/D converter. Good decoupling must be made with capacitors on the analog input and between V state while the conversion is in progress, so as to minimize noise injected into V eration of the micro-controller itself.
Finally, when enough time is available, it is highly recommended to make several successive A/D conversions and take an average of the results. This is the most effective way to get the most accuracy out of the ST6 family A/D converter.
and ground. It is also recommended to put the MCU in wait
CC
supply lines of the MCU as VCC is also the
CC
by the op-
CC
The following code fragment demonstrates a burst of 256 successive measurements, after which the average is put into the accumulator. The whole routine takes approximately 30 milli­seconds with an 8 MHz clock. When less time is available, it is of course possible to reduce the number of conversions: 8, 16 or 32 conversions also give good results, although the most con­versions give the best results.
Rev. 2.0
AN672/1104 1/3
1
Optimizing The St6 A/d Converter Accuracy
;******************** SUBROUTINE AVERAGE ***********************
;description: measures ADC input 256 times and stores average *
; of the 256 measures into accumulator *
;***************************************************************
average
lid ior,10h ; global enable interrupts
clr aver_lo ;aver_lo, aver_hi and count are RAM registers
clr aver_hi
ldi count,255
aver1
ldi adcc,10110000b ; start conversion with interrupt
wait
ld a,adc
;======================= two byte addition of adc to 16-bit word:
add a, aver_lo
jrnc aver2
inc aver_hi
aver2 ld aver_lo,a
;======================= end of two byte addition
ld a,count
jrz aver4
dec count
jp aver1 ;do it 256 times
aver4 ld a,aver_lo
cpi a,127 ;round to next value if decimal part >0.5
jrc aver3
inc aver_hi
aver3 ld a, aver_hi ;store high byte of result into accumulator,
ret
;*********************** interrupt service routine *************
adcint
ldi adcc,10h
reti
;the low byte is not significant
; set for 256 measurements
;*********************** interrupt vector **********************
.org 0ff0h
jp adcint
2/3
2
Loading...
+ 1 hidden pages