Rev. 1.00
10�
��ne ��� �01�
Rev. 1.00
109
��ne ��� �01�
HT66FM5440
Brushless DC Motor A/D Flash MCU
HT66FM5440
Brushless DC Motor A/D Flash MCU
Example: using the interrupt method to detect the end of conversion
clr
AEOCE ;
disable
A/D
interrupt
mov a,03H
mov ADCR1,a ; select f
SYS
/8 as A/D clock
clr ADOFF
mov a,01h ; setup PDPS0 to configure pin AN0
mov PDPS0,a
mov a,00h
mov ADCR0,a ; enable and connect AN0 channel to A/D converter
:
:
start_conversion:
clr ADSTR ; high pulse on start bit to initiate conversion
set ADSTR ; reset A/D
clr ADSTR ; start A/D
clr AEOCF ; clear A/D interrupt request flag
set Int_prinF ; clear related interrupt priority request flag
set
AEOCE
;
enable
A/D
interrupt
set
Int_prinE
;
enable
related
interrupt
priority
set EMI ; enable global interrupt
:
:
; A/D interrupt service routine
ADC_ISR:
mov acc_stack,a ; save ACC to user defined memory
mov a,STATUS
mov status_stack,a ; save STATUS to user defined memory
:
:
mov a,ADRL ; read low byte conversion result value
mov ADRL_buffer,a ; save result to user defined register
mov a,ADRH ; read high byte conversion result value
mov ADRH_buffer,a ; save result to user defined register
:
:
EXIT_INT_ISR:
mov a,status_stack
mov STATUS,a ; restore STATUS from user defined memory
mov a,acc_stack ; restore ACC from user defined memory
reti