Chapter 14A/D ConverterXIV - 34 OperationAn example setup procedure, with a description of each step is shown below...The result of conversion can be read out by generating an interrupt. In that case, it is notnecessary to wait for the AN0EN flag since an interrupt is generated after the result is storedin AN0BUF00...Setup Procedure Description(1) Stop the A/D converter operationAN0CTR0(0x0000A400)bp7: AN0EN=0bp5: AN0TRG=0(1) Set the AN0EN and AN0TRG flags of the A/D0conversion control register (AN0CTR0) to “0” to stopthe A/D conversion.(2) Set the AN0CTR0 registerSet the operation modeAN0CTR0(0x0000A400)bp1-0: AN0MD1-0=00Set the conversion clockAN0CTR0(0x0000A400)bp4-2: AN0CK2-0=010Set the conversion channelAN0CTR0(0x0000A400)bp10-8: AN0CH2-0=000Set the power-down modeAN0CTR0(0x0000A400)bp6: AN0OFF=1Set the AN0CTR1 registerSet the S/H cyclebp5-4: AN0SHC1-0=10(2) Set the AN0MD1-0 flags of the AN0CTR0 register to“00”to set “any single channel/one-time conversion” tooperation mode.Set the AN0CK2-0 flags of the AN0CTR0 register to“010” to set 3 dividing of IOCLK to the conversionclock.Set the AN0CH2-0 flags of the ANOCTR0 register to“000” to set “channel 0” to the conversion channel.Set the AN0OFF flag of the ANOCTR0 register to “1” toset operation mode to the power-mode flag.Set the AN0SHC1-0 flags of the AN0CTR0 register to“10” to set 4 cycles to S/H cycle.*After shifted to operation mode, more than 100nsecwait time is necessary until A/D conversion starts..(3) Start the A/D converter operationAN0CTR00(0x0000A400)bp7: AN0EN=1(3) Set the AN0EN flag of the AN0CTR0 register to “1” tostart A/D conversion. Conversion is started at the risingedge of the first A/D conversion clock after the flag isset to “1”. The conversion time is 15cycles of the A/Dconversion clock (1.5μs).(4) Wait the A/D conversion operation completedAN0CTR00(0x0000A400)bp7: AN0EN(4) Wait for conversion to be completed . The AN0EN flag ofthe AN0CTR0 register is to “1” during conversion andcleared to “0” after conversion is completed. Wait forThe AN0EN flag to be to “0” by program.(5) Read the A/D valueAN0BUF00(0x0000A410)(5) The A/D0 conversion data buffer 0 (AN0BUF00) is readout.