Chapter 15 A/D Converter

15-3-2 Setup Example

„A/D Converter Setup Example by Registers

A/D conversion is started by setting registers. The analog input pins are set to AN0, the converter clock is set to fs/4, and the sampling hold time is set to TAD x 6. Then, A/D conversion complete interrupt is generated.

An example setup procedure, with a description of each step is shown below.

Setup Procedure

 

Description

(1) Set the analog input pin.

(1) Set the analog input pin (set at the procedure

PAIMD(x'3F3C')

2) to the special function pin by the port A input

bp0 : PAIMD0 = 1

mode register (PAIMD). Also, set to no pull-up/

PAPLUD (x'3F4A')

pull-down resistance by the port A pull-up/pull-

bp0 : PAPLUD0 = 0

down resistance control register (PAPLUD),

PADIR (x'3F3A')

and to input mode by port A direction control

bp0 : PADIR0 = 0

register (PADIR).

(2) Select the analog input pin.

(2) Select the analog input pin from AN7-0 (PA7-

ANCTR1(x'3FB1')

0) by the ANCHS2-0 flag of the A/D converter

bp2-0 : ANCHS2-0 = 000

control register 1 (ANCTR1).

(3) Select the A/D converter clock.

(3) Select the A/D converter clock by the

ANCTR0 (x'3FB0')

ANCK1, ANCK0 flag of the A/D converter

bp5-4 : ANCK1-0 = 01

control register 0 (ANCTR0).

(4) Set the sample and hold time.

(4) Set the sample and hold time by the ANSH1,

ANCTR0 (x'3FB0')

ANSH0 flag of the A/D converter control

bp7-6 : ANSH1-0 = 01

register 0 (ANCTR0).

(5) Set the interrupt level.

(5) Set the interrupt level by the ADLV1-0 flag of

ADICR (x'3FFA')

the A/D conversion complete interrupt control

bp7-6 : ADLV1-0 = 00

register (ADICR). If any interrupt request flag

 

is already set, clear them.

 

[

Chapter 3. 3-1-4 Interrupt Flag Setting ]

(6) Enable the interrupt.

(6) Enable the interrupt by setting the ADIE flag

ADICR (x'3FFA')

the ADICR register to "1".

bp1 : ADIE = 1

 

 

 

 

 

XV - 12 Operation

Page 486
Image 486
Panasonic MN101C77C, F77G user manual Interrupt Flag Setting