![](http://datasheet.mmic.net.cn/Freescale-Semiconductor/MC68HC16Z1VEH16_datasheet_98737/MC68HC16Z1VEH16_47.png)
4.6.1 ADC Initialization Example
This program initializes the ADC and samples the AD0 pin. It uses the single-channel four conversion
sequence. The most recent conversion will be in the E register, and its format will be right-justified un-
the range of VRH and VRL.
This example is in the file “adc_init.asm” in the archive “16Z1_init” on the Freeware Data System.
INCLUDE
'EQUATES.ASM'
;register equates
INCLUDE
'INIT_RES.ASM' ;initialize reset vector
INCLUDE
'INIT_INT.ASM' ;initialize interrupt vectors
ORG
$200
CLRE
INIT_SIM:
LDAB
#$0F
;set K fields to $F to point to internal regs
TBEK
LDAA
#$7F
STAA
SYNCR
;increase clock speed
CLR
SYPCR
;disable software watchdog
INIT_ADC:
LDD
#$0000
STD
ADCMCR
;enable ADC
LDD
#$0043
;STS field = 8 A/D clocks
STD
ADCTL0
;8-bit, sample period=SYS CLOCK/8
START_ADC:
LDD
#$0000
STD
ADCTL1
;single 4 conversion, single channel, AD0
;writing to the ADCTL1 reg starts conversion
LDAA
#$80
SEE_IF_DONE:
BITA
ADSTAT
;check for the Sequence Complete Flag
BEQ
SEE_IF_DONE
;wait until conversion is complete
LDE
RJURR0
;read result in lower byte of register
BRA
START_ADC
;go get another sample
INT
RTI
;unused interrupts point here
5 Troubleshooting
Because of the complexity of the MCU, there are a considerable number of potential ‘fatal flaws’ that
can cause a prototype application to either not operate from power up or to fail soon after. This section
covers common problems, causes, and fixes. This is not an exhaustive discussion, but it is intended to
be used as a check list of the main problem areas that can cause an application to fail.
5.1 Critical Signals to Check
RESET should stay low for at least 512 clocks during a power-on reset. If using the internal PLL, RE-
SET will remain low for a little longer because the VCO must lock first. RESET should then go high
and remain high.
CLKOUT should be at the system clock frequency. If MODLCK is held high at the release of reset,
CLKOUT should be 512 times the frequency going into EXTAL (8.389 MHz for a 32.768 kHz crystal).
Make sure that the frequency is exact, as a measurable error may indicate limp mode and oscillator
faults. If MODCLK is held low at the release of reset, the frequency on CLKOUT should be the fre-
quency going into EXTAL.
Immediately after reset, CSBOOT should pulse low five times for a 16-bit port and nine times for an 8-
bit port.
FREEZE should be low and HALT should be high. Otherwise, the MCU is halted, or is in BDM.
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
..
.