Home
Using the M16C/62 Analog to Digital Converter in Single Sweep Mode
Contents
1. A D register 2 A D register 3 A D register 4 Decoder A D register 5 A D register 6 A D register 7 AAAAA AA AA A Data bus high order Y Data bus low order YVVVVVVY CH2 CH1 CHO 000 CH2 CH1 CHO 001 Omo OQ o CH2 CH1 CHO 010 Oo CH2 CH1 CH0 011 CH2 CH1 CH0 100 OO OPA1 OPA0 0 0 CH2 CH1 CHO 101 CH2 CH1 CHO 110 CH2 CH1 CHO 111 OPA1 OPA0 1 1 OOS oo OPA1 OPA0 0 1 REU05B0005 0100Z VIN Comparator OPA1 OPAO 0 0 Normal operation 0 1 ANEX0 1 0 ANEX1 1 1 External op amp mode Figure 1 Internal Circuitry for ADC Block Overview June 2003 Page 1 of 7 M16C 62 Q E NI ESAS Using the M16C 62 Analog to Digital Converter in Single Sweep Mode 3 0 Single Sweep Mode Description In single sweep mode multiple pins of the ADC can be selected as the input source Once triggered a single conversion takes place on each of the selected pins and the result is stored in the ADC result registers corresponding to the selected channels An interrupt is generated signifying the completion of the conversions Figure 2 and Figure 3 are overviews of the registers that will be used in this example These registers are detailed in the included sample code A D control register 0 Note 1 b7 b6
2. 00101001 Single sweep mode software trigger fAD 2 analog input select bit 0 analog input select bit 1 analog input select bit 2 A D operation mode select bit 0 A D operation mode select bit 1 trigger select bit A D conversion start flag frequency select bit 10 bit mode fAD divided Vref connected A D sweep pin select bit 0 A D sweep pin select bit 1 A D operation mode select bit 1 8 10 bit mode select bit frequency select bit 1 Vref connect bit external op amp connection bit 0 external op amp connection bit 1 sample and hold enabled sample and hold select bit reserved reserved reserved reserved reserved reserved reserved REU05B0005 0100Z June 2003 Page 5 of 7 M16C 62 oe gt Cc Ni ESAS Using the M16C 62 Analog to Digital Converter in Single Sweep Mode adic 0x01 00000001 Set Priority Level to Enable the ADC interrupt interrupt priority select bit 0 interrupt priority select bit 1 interrupt priority select bit 2 interrupt request bit reserved reserved reserved reserved _asm fset i globally enable interrupts adst 1 J Start a eonversion here while 1 Program waits here forever xx ADCInt PARAMETERS None DESCRIPTION Interrupt routine of the ADC Here the converted value is loaded into a variable and masked off to show the result RETURNS Nothing ad void ADCInt void TempStore0 adO amp OxO
3. CENESAS APPLICATION NOTE M16C 62 Using the M16C 62 Analog to Digital Converter in Single Sweep Mode 1 0 Abstract The following article outlines the steps necessary to set up perform and read a single sweep conversion using the onboard analog to digital converter ADC of the M16C The ADC is useful in measuring output voltages of sensors such as accelerometers or other analog instrumentation and converting them to digital values 2 0 Introduction The M16C line of devices features an onboard analog to digital converter ADC The ADC consists of one 10 bit successive approximation circuit with a capacitive coupled amplifier There are eight analog input pins selectable conversion clock speeds sample and hold function and several conversion modes Figure 1 is an overview of the internal circuitry for the ADC block CKS1 1 O wo s AD A D conversion rate selection CKS1 0 Resistor ladder CEPT CEE Successive conversion register A D control register 1 address 03D716 A D control register 0 address 03D616 Addresses ANEX0 O ANEX1 O 03C116 03C016 03C316 03C216 03C516 030416 03C716 03C616 030916 03C816 03CB16 03CA16 03CD16 03CC16 O3CF16 O3CE16 A D register 0 my A D register 1
4. b5 b4 b3 b2 bi bO Symbol Address When reset ADCONO 03D616 00000XXX2 Erma ANo is selected AN1 is selected AN2 is selected AN3 is selected AN4 is selected AN5 is selected AN6 is selected AN7 is selected A D operation mode select bit 0 One shot mode Repeat mode Single sweep mode Repeat sweep mode 0 Repeat sweep mode 1 Trigger select bit 0 Software trigger 1 ADTRG trigger A D conversion start flag 0 A D conversion disabled ADST 1 A D conversion started Frequency select bit 0 0 fAD 4 is selected CKSO 1 faD 2 is selected Note 1 If the A D control register is rewritten during A D conversion the conversion result is indeterminate Note 2 When changing A D operation mode set analog input pin again A D control register 1 Note b7 b6 b5 b4 b3 b2 bi b0 Symbol Address When reset ADCON1 03D716 0016 Bamba A D sweep pin select bit When single sweep and repeat sweep mode 0 are selected b1 b0 0 0 ANo AN1 2 pins 0 1 ANo to AN3 4 pins 10 ANo to AN5 6 pins 11 ANo to AN7 8 pins When repeat sweep mode 1 is selected b1 b0 00 ANo 1 pin 0 1 ANo AN1 2 pins 10 ANo to AN2 3 pins 11 ANo to AN8 4 pins A D operation mode 0 Any mode other than repeat sweep MD2 select bit 1 mode 1 1 Repeat sweep mode 1 BITS 8 10 bit mode select bit 0 8 bit mode 1 10 bit mode Frequency select bit 1 0 faD 2 or faD 4 is selected CKS1 1 fAD is sel
5. the information contained herein Renesas Technology Corporation 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 Corporation or an authorized Renesas Technology Corporation 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 Corporation 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 Corporation for further details on these materials or the products contained therein
6. 03ff Mask off the upper 6 bits of the variable leaving only the result in the variable itself TempStorel adl amp OxO03ff Mask off the upper 6 bits of the variable leaving only the result in the variable itself TempStore2 ad2 amp Ox03ff Mask off the upper 6 bits of the variable leaving only the result in the variable itself TempStore3 ad3 amp Ox03ff Mask off the upper 6 bits of the variable leaving only the result in the variable itself In order for this program to run properly the ADC interrupt vector needs to point to the function The interrupt vector table is near the end of the startup file sect30 inc Insert the function label ADCInt into the interrupt vector table at vector 14 as shown below REU05B0005 0100Z June 2003 Page 6 of 7 CENESAS M16C 62 Using the M16C 62 Analog to Digital Converter in Single Sweep Mode section OLO lword lt OL gt lword lword lword lword lword lword lword lword lword lword GLD lword lword lword lword dummy int VECTOR _ADR 16 dummy int dummy int dummy int dummy int dummy int dummy int dummy int dummy int dummy int dummy int ADOTE ADCInt dummy int dummy int dummy int vector VECTOR ADR variable vector table BRK vector 0 int3 for user vector 4 timerBS for user vector 5 timerB4 for user vector 6 timerB3 for user vector 7 si o4 in
7. ected Vref connect bit 0 Vref not connected b7 b6 FAR bit 0 0 ANEXO and ANEX1 are not used 0 1 ANEXO input is A D converted 10 ANEX1 input is A D converted 1 1 External op amp connection mode Note If the A D control register is rewritten during A D conversion the conversion result is indeterminate Figure 2 A D Converter Related Registers REU05B0005 0100Z June 2003 Page 2 of 7 M16C 62 w gt Cc Ni ESAS Using the M16C 62 Analog to Digital Converter in Single Sweep Mode A D control register 2 Note Z b6 b5 b4 b3 b2 bi b0 Symbol Address When reset POPAL AE oe 0000XXX02 l r a 4 Bit symbol Bit name Function 3 A D conversion method 0 Without sample and hold select bit 1 With sample and hold Reserved bit Always setto o set to Aways setto o Nothing is assigned Write 0 when writing to these bits When read the value is 0 Note 1 If the A D control register is rewritten during A D conversion the conversion result is indeterminate Symbol Address When reset ADi i 0 to 7 03C016 to O3CF 16 Indeterminate A D register b15 b8 b7 bO b7 i i Eight low order bits of A D conversion result e During 10 bit mode Two high order bits of A D conversion result e During 8 bit mode When read the content is indeterminate Nothing is assigned Write 0 when writing to these bits When read the value is 0 Figure 3 A D Converter Related Register 4 0 Example Program This
8. example program demonstrates how to perform a conversion using the ADC in the following environment Environment Setup e Single sweep conversion e 10 bit mode e Analog inputs 0 3 used e Sample and hold enabled e Vref connected e Conversion clock used will be fap 2 e Software conversion start ADC Software Setup Set the ADCONO register for single sweep mode 0 operation fap 2 0x90 Set the ADCON 1 register for 10 bit mode fap divided ANO 3 sweep and connect Vref 0x29 Set the ADCON2 register for sample and hold 0x01 Enable the A D converter by setting the ADST bit to 1 Read current A D channel values in the variables TempStore x in the AD Interrupt Service Routine REU05B0005 0100Z June 2003 Page 3 of 7 M16C 62 oe gt Cc Ni ESAS Using the M16C 62 Analog to Digital Converter in Single Sweep Mode 5 0 Reference Renesas Technology Corporation Semiconductor Home Page http www renesas com E mail Support support _apl renesas com Data Sheets e M16C 62 datasheets 62aeds pdf User s Manual e NC30 Ver 4 0 User s Manual NC30UE pdf e M16C 60 and M16C 20 C Language Programming Manual 6020EC pdf e M16C 62 User s Manual 62eum pdf e Application Note Writing Interrupt Handlers in C for the M16C 6 0 Software Code The sample software provided was written using the NC30 compiler The program performs one set of conversions on reset This code could be simply modified to use a timer for
9. t 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 Corporation without notice due to product improvements or other reasons It is therefore recommended that customers contact Renesas Technology Corporation or an authorized Renesas Technology Corporation 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 Corporation 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 Corporation by various means including the Renesas Technology Corporation 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 Corporation assumes no responsibility for any damage liability or other loss resulting from
10. t5 for user vector 8 sifo3 int4 for user vector 9 Bus collision detection for user v10 DMAO for user vector 11 DMA1 for user vector 12 Key input interrupt for user vect 14 A D for user vector 14 uart2 transmit for user vector 15 uart2 receive for user vector 16 uartO transmit for user vector 17 REU05B0005 0100Z June 2003 Page 7 of 7 Keep safety first in your circuit designs Renesas Technology Corporation 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 These materials are intended as a reference to assist our customers in the selection of the Renesas Technology Corporation 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 Corporation or a third party Renesas Technology Corporation assumes no responsibility for any damage or infringement of any third party s rights originating in the use of any produc
11. the trigger of the ADC to provide multiple conversions at specific intervals KK KK KKK KK KK KK KK KK KK KK KK KK KK KK KK KK KK KK KK KK KK KK kK KK Kk KK DESCRIPTION single sweep c AUTHOR Renesas Technology Corporation June 2003 mode On reset program stores the results of the conversions in variables that can be examined using PURPOSE Outlines how to use the M16C 62 ADC in single sweep KD30 and the MSVle32 62 Starter Kit ok I KK IK Kk KK IK KK kK KK KK KK KK KK KK KK KK KK OK KK KK KK KK KK KK include Ssire2 h unsigned int TempStore0O 0x0000 Location where ANO result is stored unsigned int TempStorel 0x0000 Location where AN1 result is stored unsigned int TempStore2 0x0000 Location where AN2 result is stored unsigned int TempStore3 0x0000 Location where AN3 result is stored pragma INTERRUPT ADCInt compiler directive indicating the proper return method for this function REIT vs RTS REU05B0005 0100Z June 2003 Page 4 of 7 CENESAS M16C 62 Using the M16C 62 Analog to Digital Converter in Single Sweep Mode void ADCInt void Je xk main x PARAMETERS None x DESCRIPTION Main function x RETURNS Nothing Where program execution starts Sets up the ADC then waits for interrupt to occur void main void adconO 0x90 10010000 eee adconl 0x29 ANO 3 adcon2 0x017 00000
Download Pdf Manuals
Related Search
Related Contents
EcoOnline™ Pump System Manual 取扱説明書 Benutzerhandbuch CM-DPV1 MANUEL D`UTILISATION - BS&B Safety Systems Copyright © All rights reserved.
Failed to retrieve file