
REJ05B0442-0100Z/Rev.1.00 March 2004 Page 7 of 13
M16C/62 Group
A-D Converter OP-AMP Gain Adjustment Connection Mode
6. The example of a reference program
The following program shows a sequential reading of gain amplified value from AN0 to AN7 by connecting to external
operational amplifier.
;**********************************************************************
;
; M16C/62 Group Program Collection
;
; FILE NAME : rjj05b0441_src.a30
; CPU : M16C/62 Group
; FUNCTION : The example of A-D conversion at the time of external
; operational amplifier gain adjustment
; HISTORY : 2004.01.15 Ver 1.00
;
; Copyright (C) 2004. Renesas Technology Corp.
; Copyright (C) 2004. Renesas Solutions Corp.
; All right reserved.
;
;**********************************************************************
; ----- include define -----
.list off
.include sfr62p.inc
.list on
;
; ----- Symbol define -----
vstack .equ 0002b00h ; Stack Pointer
vram .equ 0000400h ; Internal RAM area
vram_end .equ 0002c00h ;
vpro .equ 00fc000h ; Program Start address
vval_vec .equ 00ffd00h ; Variable vector address
vvector .equ 00fffdch ; Non-maskable vector address
;
; ----- Internal RAM Area -----
.section ramdata,data
.org vram
;
; ----- Program Area -----
.section program,code
.org vpro
reset:
;
; ----- Initial setting -----
ldc #vstack,sp ; Set stack-pointer address
ldintb #vval_vec ; Set variable vector table address
;
mov.b #003h, prcr
mov.b #008h, cm0
mov.b #020h, cm1 ; main-clock divid by 0 mode
mov.b #000h, prcr
mov.w #00000h, p0
mov.w #0ffffh, pd0 ; Port0/1 output select
mov.w #00000h, p2
mov.w #0ffffh, pd2 ; Port2/3 output select
mov.w #00000h, p4
mov.w #0ffffh, pd4 ; Port4/5 output select
mov.w #00000h, p6
mov.w #0ffffh, pd6 ; Port6/7 output select
bset prc2
mov.b #000h, pd9 ; P9_5(ANEX0) & P9_6(ANEXq) is input port
mov.b #000h, pd10 ; P10_0(AN0) to P10_7(AN7) is input port
;
;----- Evaluation start -----
start:
mov.b #00000001b, adcon2
; | ||+--------------------- conversion mode select : sample&hold
; | ++---------------------- input group select : select P10 group
; +------------------------- Freq select bit2 : fAD/2
mov.b #10000000b, adcon0
; |||||+++--------------------- input select : AN0 select
; |||++------------------------ mode select bit0 : single mode
; ||+-------------------------- trigger select : software
; |+--------------------------- AD start flag : stop
; +---------------------------- Freq select bit0 : fAD/2