38D2 Group Application Note AD Converter (8-bit AD Mode)

4 downloads 205 Views 69KB Size Report
Apr 2, 2007 ... APPLICATION NOTE. Page 1 of 7. 1. Abstract. The following article introduces and shows an example of how to use the AD Converter (8-bit ...
APPLICATION NOTE

38D2 Group AD Converter (8-bit A/D Mode) 1. Abstract The following article introduces and shows an example of how to use the AD Converter (8-bit A/D Mode) on the 38D2 Group device.

2. Introduction The application explained in this document applies to the following MCU: Applicable MCU: 38D2 Group This sample program may include operations of unused bit functions for the convenience of the SFR bit layout. Set the values according to the operational conditions of the user system.

REJ05B0990-0100/Rev.1.00

February 2007

Page 1 of 7

38D2 Group AD Converter (8-bit A/D Mode) 3. Contents 3.1 Analog Signal Read in 8-bit A/D Mode Outline: The analog input voltage from a sensor is converted to digital values. Specifications: •The analog input voltage from a sensor is converted to digital values. •The P40/AN0 pin is used as an analog input pin. •8-bit A/D mode Figure 3.1 shows a Connection Diagram, Figure 3.2 shows the Relevant Register Settings, and Figure 3.3 shows the Control Procedure.

P40/AN0

Sensor

38D2 Group

Figure 3.1

Connection Diagram

REJ05B0990-0100/Rev.1.00

February 2007

Page 2 of 7

38D2 Group AD Converter (8-bit A/D Mode)

P o rt P 4 d ire c tio n re g is te r (a d d re s s : 0 0 0 9 h ) b7

b0 0

P4D

P 4 0 /A N 0 : In p u t m o d e P U L L re g is te r (a d d re s s : 0 F F 0 h ) b7 PULL

b0

0

0

P 4 0 to P 4 3 : N o p u ll-u p O s c illa tio n o u tp u t c o n tro l re g is te r (a d d re s s : 0 0 1 0 h ) b7 OSCOUT

0

b0 0

0

0

0

0

0

0

P 4 0 /P 4 3 o s c illa tio n o u tp u t c o n tro l: P 4 1 , P 4 0

n o rm a l p o rt

A /D c o n tro l re g is te r (a d d re s s : 0 0 1 5 h ) b7 ADCON

0

b0 1

0

1

0

0

0

A n a lo g in p u t p in s : S e le c t A N 0 0: A /D c o n v e rs io n c o m p le tio n b it ⎨ 1 :

A /D c o n v e rs io n s ta rts A /D c o n v e rs io n c o m p le te d (N o te 1 )

A D K E Y e n a b le b it: D is a b le d 1 0 -b it o r 8 -b it c o n v e rs io n s w itc h b it: S e le c t 8 -b it A /D A D K E Y s e le c tio n b it: V a lid A D c o n v e rs io n re g is te r (lo w -o rd e r) (a d d re s s : 0 0 1 6 h ) b7 ADL

0

b0 0

0

0

0

0

0

0

V R E F in p u t s w itc h b it ⎨ 0 : A U T O 1: O N A D c o n v e rs io n re g is te r (h ig h -o rd e r) (a d d re s s : 0 0 1 7 h ) b7 ADH

b0

b7 b6 b5 b4 b3 b2 b1 b0

(R e a d -o n ly ) S to re A /D c o n v e rs io n re s u lts (N o te 2 )

In te rru p t re q u e s t re g is te r 2 (a d d re s s : 0 0 3 D h ) b7 IR E Q 2

0

b0 0

N o A /D c o n v e rs io n in te rru p t re q u e s t is s u e d In te rru p t c o n tro l re g is te r 2 (a d d re s s : 0 0 3 F h ) b7 IC O N 2

0

b0 1

A /D c o n v e rs io n in te rru p t e n a b le d N o te s: 1 . A /D c o n v e rs io n is s ta rte d w h e n A /D c o n v e rs io n c o m p le tio n b it is s e t to 0 . O n ly 0 is v a lid w h e n w ritin g to A /D c o n v e rs io n c o m p le tio n b it a n d e v e n if 1 is w ritte n , th is b it is n o t s e t to 1 . T h e re fo re , w h e n w ritin g v a lu e to A D C O N w ith o u t a ffe c tin g A /D c o n v e rs io n c o m p le tio n b it, s e t A /D c o n v e rs io n c o m p le tio n b it to 1 . 2 . R e a d th e A /D c o n v e rs io n re s u lt a fte r A D c o n v e rs io n c o m p le tio n b it is s e t to 1 . W h e n re a d in g th e A /D c o n v e rs io n re s u lt in 8 -b it A /D m o d e , re a d th e A D c o n v e rs io n h ig h -o rd e r re g is te r o n ly .

Figure 3.2

Relevant Register Settings

REJ05B0990-0100/Rev.1.00

February 2007

Page 3 of 7

38D2 Group AD Converter (8-bit A/D Mode)

• X : N ot used in this application. S et to 0 or 1 according to use. O SO U T (address: 0010h) ← 00000000b P 4D (address: 0009h) ← X X X X X X X0b PU LL (address: 0FF 0h) ← 0X X X X 0X X b IC O N 2 (address: 003F h), bit 6 ← 0 AD C O N (address: 0015h) ← 010X 1000b AD L (address: 0016h) ← 00000000b NOP IR EQ 2 (address: 003D h), bit 6 ← 0 IC O N 2 (address: 003Fh), bit 6 ← 1 AD C O N (address: 0015h), bit 3 ← 0 C LI

• P 4 0 /AN 0 pin: N orm al port • P 4 0 /AN 0 pin: Input m ode • P 4 0 /AN 0 pin: N o pull-up • A /D conversion interrupt disabled • S elect A N 0 pin • V R E F input sw tich A U TO • • • •

N o A /D conversion interrupt request issued A /D conversion interrupt enabled S tart A /D conversion Interrupt enabled

A /D conversion interrupt routine C LT C LD P ush registers to the stack

R ead data of A D H (address: 0017h)

• Set X index m ode flag • S et decim al m ode flag • P ush registers used in interrupt routine to the stack

• R ead conversion results

≈ • Pop registers from the stack P op registers

R TI

Figure 3.3

Control Procedure

REJ05B0990-0100/Rev.1.00

February 2007

Page 4 of 7

38D2 Group AD Converter (8-bit A/D Mode) 4. Sample Programming Code Download a sample program from the Renesas Technology website. To download, click “Application Notes” in the left side menu on the page of the 38D2 Group.

5. Reference Datasheet 38D2 Group Datasheet Download the latest version from the Renesas Technology website. Technical News/Technical Update Download the latest information from the Renesas Technology website.

REJ05B0990-0100/Rev.1.00

February 2007

Page 5 of 7

38D2 Group AD Converter (8-bit A/D Mode) Website and Support Renesas Technology website http://www.renesas.com Inquiries http://www.renesas.com/inquiry [email protected]

REVISION HISTORY

Rev.

Date

1.00

Feb 9, 2007

38D2 Group AD Converter (8-bit A/D Mode) Description

Page

REJ05B0990-0100/Rev.1.00



Summary First Edition issued

February 2007

Page 6 of 7

38D2 Group AD Converter (8-bit A/D Mode)

Keep safety first in your circuit designs! 1.

Renesas Technology Corp. puts the maximum effort into making semiconductor products better and more reliable, but there is always the possibility that trouble may occur with them. Trouble with semiconductors may lead to personal injury, fire or property damage. Remember to give due consideration to safety when making your circuit designs, with appropriate measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of nonflammable material or (iii) prevention against any malfunction or mishap.

Notes regarding these materials 1.

2.

3.

4.

5.

6. 7.

8.

These materials are intended as a reference to assist our customers in the selection of the Renesas Technology Corp. product best suited to the customer's application; they do not convey any license under any intellectual property rights, or any other rights, belonging to Renesas Technology Corp. or a third party. Renesas Technology Corp. assumes no responsibility for any damage, or infringement of any third-party's rights, originating in the use of any product data, diagrams, charts, programs, algorithms, or circuit application examples contained in these materials. All information contained in these materials, including product data, diagrams, charts, programs and algorithms represents information on products at the time of publication of these materials, and are subject to change by Renesas Technology Corp. without notice due to product improvements or other reasons. It is therefore recommended that customers contact Renesas Technology Corp. or an authorized Renesas Technology Corp. product distributor for the latest product information before purchasing a product listed herein. The information described here may contain technical inaccuracies or typographical errors. Renesas Technology Corp. assumes no responsibility for any damage, liability, or other loss rising from these inaccuracies or errors. Please also pay attention to information published by Renesas Technology Corp. by various means, including the Renesas Technology Corp. Semiconductor home page (http:// www.renesas.com). When using any or all of the information contained in these materials, including product data, diagrams, charts, programs, and algorithms, please be sure to evaluate all information as a total system before making a final decision on the applicability of the information and products. Renesas Technology Corp. assumes no responsibility for any damage, liability or other loss resulting from the information contained herein. Renesas Technology Corp. semiconductors are not designed or manufactured for use in a device or system that is used under circumstances in which human life is potentially at stake. Please contact Renesas Technology Corp. or an authorized Renesas Technology Corp. product distributor when considering the use of a product contained herein for any specific purposes, such as apparatus or systems for transportation, vehicular, medical, aerospace, nuclear, or undersea repeater use. The prior written approval of Renesas Technology Corp. is necessary to reprint or reproduce in whole or in part these materials. If these products or technologies are subject to the Japanese export control restrictions, they must be exported under a license from the Japanese government and cannot be imported into a country other than the approved destination. Any diversion or reexport contrary to the export control laws and regulations of Japan and/ or the country of destination is prohibited. Please contact Renesas Technology Corp. for further details on these materials or the products contained therein.

© 2007. Renesas Technology Corp., All rights reserved. REJ05B0990-0100/Rev.1.00

February 2007

Page 7 of 7