EasyManua.ls Logo

Cmsemicon SC8F577 Series - A;D Conversion Procedure

Default Icon
181 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
V1.8
SC8F577x
79 / 181
www.mcu.com.cn
10.3.5 A/D conversion procedure
The following steps give an example of using ADC for analog-to-digital conversion:
1. port configuration:
Disable pin output driver (see TRIS register);
Configure pin as analog input pin.
2. configuration ADC mod:
Select ADC reference voltage (AD conversion must be wait for up to 100us if the reference voltage
switches from VDD to internal LDO);
Select ADC conversion clock;
Select ADC input channel;
Choose the format of the result;
Start the ADC mod.
3. configuration ADC interrupt (optional):
Clear ADC interrupt flag bit;
Allow ADC interrupt;
Allow peripherals interrupt;
Allow global interrupt.
4. Wait for the required acquisition time.
5. Set GO/
DONE
to 1 to start conversion.
6. Wait for the ADC conversion to end by one of the following methods:
Query GO/ ("
DONE
) bit
Wait for ADC interrupt (allow interrupt).
7. Read ADC results.
8. Clear the ADC interrupt flag bit (if interrupt is allowed, this operation is required).
9. At least wait for 2 TAD times to start AD conversion again When GO/ ("
DONE
) bit change from 1 to
0 or ADIF change from 0 to 1.
Note: If the user tries to resume sequential code execution after waking the device from sleep mode,
the global interrupt must be disabled.
exampleAD conversion
LDIA
B10000000
LD
ADCON1, A
SETB
TRISA, 0
;set PORTA.0 as input
LDIA
B11000001
LD
ADCON0, A
CALL
DELAY
;delay
SETB
ADCON0, GO
SZB
ADCON0, GO
;wait ADC to complete
JP
$-1
LD
A, ADRESH
;save the highest bit of ADC
LD
RESULTH, A
LD
A, ADRESL
; save the lowest bit of ADC
LD
RESULTL, A

Related product manuals