background image

Figure 6-4. ADC0.CTRLA - Enable ADC0

Bit

7

6

5

4

3

2

1

0

RUNSTDBY

CONVMODE

LEFTADJ

RESSEL[1:0]

FREERUN

Access

R/W

R/W

R/W

R/W

R/W

R/W

R/W

Reset

0

0

0

0

0

0

0

Bit 0 – ENABLE

 

ADC Enable

Value

Description

0

ADC is disabled

ENABLE

1

ADC is enabled

/*Enable ADC0*/

ADC0.CTRLA = ADC_ENABLE_bm;

It is now possible to start measurement by writing a ‘

1

’ to the STCON (Start Conversion) bit in the Command

(ADC0.COMMAND) register.

Figure 6-5. ADC0.COMMAND - Start a Measurement

Bit

7

6

5

4

3

2

1

0

SPCONV

Access

R/W

R/W

Reset

0

0

Bit 0 – STCONV

 

Start Conversion

Writing a ‘

1

’ to this bit will start a conversion as soon as any ongoing conversions are completed. If in Free-Running

mode, this will start the first conversion. STCONV will read as ‘

1

’ as long as a conversion is in progress. When the

conversion is complete, this bit is automatically cleared. Writing a ‘

0

’ to this bit has no effect.

STCONV

/*Start an ADC conversion*/

 ADC0.COMMAND = ADC_STCONV_bm;

After a conversion is started, it is necessary to wait for it to be done before reading the result. The RESRDY (Result
Ready) interrupt flag in the Interrupt Flags (ADC0.INTFLAGS) register will be triggered when a result is ready in the
Result (ADC0.RES) register.

Figure 6-6. ADC0.INTFLAGS - Check RESRDY Interrupt Flag

Bit

7

6

5

4

3

2

1

0

WCMP

Access

R/W

R/W

Reset

0

0

Bit 1 – WCMP

 

Window Comparator Interrupt Flag

This window comparator flag is set when the measurement is complete and if the result matches the selected
Window Comparator mode defined by the WINCM bit field in the Control E (ADCn.CTRLE) register. The comparison
is done at the end of the conversion. The flag is cleared by either writing a ‘

1

’ to the bit position or by reading the

Result (ADCn.RES) register. Writing a ‘

0

’ to this bit has no effect.

Bit 0 – RESRDY

 

Result Ready Interrupt Flag

The Result Ready interrupt flag is set when a measurement is complete and a new result is ready. The flag is cleared
by either writing a ‘

1

’ to the bit location or by reading the Result (ADCn.RES) register. Writing a ‘

0

’ to this bit has no

effect.

RESRDY

/*Wait for the ADC conversion to be done*/

while(!(ADC0.INTFLAGS & ADC_RESRDY_bm));

The result can be read in the Result (ADC0.RES) register. The result must be divided by 16 due to the oversampling.
This is easily done by right shifting the value in ADC0.RES 4 bits. The RESRDY interrupt flag will be automatically
cleared when ADC0.RES is read.

 TB3287

Measuring VDDIO2

©

 2020 Microchip Technology Inc.

 Technical Brief

DS90003287A-page 13

Содержание TB3287

Страница 1: ...nal components running on a different voltage level Eliminating external logic level shifters will in turn reduce the BOM and free up PCB real estate Figure 1 Multi Voltage I O can Completely Replace External Logic Level Converters VDD 1 8 5 5V VDD VDD VDDIO2 GND GND GND GND GND VDDIO2 1 8 5 5V Microcontroller Logic Level Converter Sensor MVIO Sensor Sensor Sensor This technical brief describes ho...

Страница 2: ...th VDD at 1 8V A basic example of MVIO blinking an LED with a forward voltage higher than VDD Note The code examples were developed on AVR128DB48 Curiosity Nano EV35L43A and are available on GitHub TB3287 2020 Microchip Technology Inc Technical Brief DS90003287A page 2 ...

Страница 3: ...2 Status 10 6 Measuring VDDIO2 11 7 Blinking a 3V LED with VDD at 1 8V 15 8 References 17 9 Revision History 18 10 Appendix 19 The Microchip Website 22 Product Change Notification Service 22 Customer Support 22 Microchip Devices Code Protection Feature 22 Legal Notice 23 Trademarks 23 Quality Management System 24 Worldwide Sales and Service 25 TB3287 2020 Microchip Technology Inc Technical Brief D...

Страница 4: ...vide the same or more features Horizontal migration to the left reduces the pin count and therefore the available features Devices with different Flash memory sizes typically also have different SRAM and EEPROM Figure 1 1 AVR DB Family Overview Pins Flash AVR64DB28 AVR128DB28 AVR32DB28 AVR128DB32 AVR128DB48 AVR128DB64 AVR64DB32 AVR64DB48 AVR64DB64 AVR32DB32 AVR32DB48 28 48 64 32 32 KB 64 KB 128 KB...

Страница 5: ...ND GND AVDD PD4 Power Power Supply Ground Pin on AVDD Power Domain Functionality Programming Debug Clock Crystal Analog Function Digital Function Only Pin on VDD Power Domain Pin on VDDIO2 Power Domain These pins are capable of the same digital behavior as regular I O pins for example GPIO serial communication USART SPI I2C or connected to PWM peripherals The input Schmitt Trigger levels are scale...

Страница 6: ...DIO2 VDD PORTx 7 0 PORTy 7 0 VDDIO2 PORT VDDIO2S VDDIO2F Enable Int Req ADC Input Edge Detector Voltage Divider Voltage Monitor Voltage Monitor VDDCORE VDDCORE TB3287 Overview 2020 Microchip Technology Inc Technical Brief DS90003287A page 6 ...

Страница 7: ...onnect VDDIO2 to 3 3V of a second power voltage source 3 Connect VDDIO2 to GND of a second voltage source Refer to the AVR123DB48 Curiosity Nano User Guide for a guide on how to reverse this process Any voltage between 1 8V and 5 5V may be applied to VDDIO2 but for the following examples we will run at 3 3V Figure 3 1 AVR128DB48 Curiosity Nano MVIO 1 2 3 Figure 3 2 Snippet From the AVR128DB48 Curi...

Страница 8: ...stem Configuration 1 Name SYSCFG1 Offset 0x06 Default 0x08 Property The default value given in this fuse description is the factory programmed value and should not be mistaken for the Reset value Bit 7 6 5 4 3 2 1 0 SUT 2 0 Access R R R R R Default 0 1 0 0 0 Bits 4 3 MVSYSCFG 1 0 This bit field controls the power supply mode Value Name Description 0x00 Reserved 0x02 SINGLE Device used in a single ...

Страница 9: ...0 Bit 0 VDDIO2S VDDIO2 Status This bit shows the state of the VDDIO2 voltage level Writing to this bit has no effect Value Description 0 The VDDIO2 supply voltage is below the acceptable range for operation The MVIO pins are tri stated VDDIO2S The VDDIO2 supply voltage is within the acceptable range for operation The MVIO pin configurations are loaded from the corresponding PORT registers 1 Pollin...

Страница 10: ...he MVIO vector will be called when the interrupt is triggered Before returning from the Interrupt Service Routine ISR the VDDIO2 VDDIO2IF interrupt flag in the MVIO Interrupt Flags MVIO INTFLAGS register must be cleared This is done by writing a 1 to the flag Figure 5 2 MVIO INTFLAGS Clear VDDIO2 Interrupt Flag Bit 7 6 5 4 3 2 1 0 Access R W Reset 0 Bit 0 VDDIO2IF VDDIO2 Interrupt Flag This flag i...

Страница 11: ...elect This bit field controls the reference voltage level for ADC0 Note 1 The values given for internal references are only typical Refer to the Electrical Characteristics section for further details Value Name Description 0x1 2V048 Internal 2 048V reference 1 0x2 4V096 Internal 4 096V reference 1 0x3 2V500 Internal 2 500V reference 1 0x4 Reserved 0x5 VDD VDD as reference 0x6 VREFA External refere...

Страница 12: ...ilt in support for oversampling This is especially useful when measuring a DC voltage as it mitigates a lot of the periodic noise Figure 6 3 ADC0 CTRLB Enabling Oversampling with 16 Samples Bit 7 6 5 4 3 2 1 0 Access R W R W R W Reset 0 0 0 Bits 2 0 SAMPNUM 2 0 Sample Accumulation Number Select This bit field selects how many consecutive ADC sampling results are accumulated automatically When this...

Страница 13: ...ered when a result is ready in the Result ADC0 RES register Figure 6 6 ADC0 INTFLAGS Check RESRDY Interrupt Flag Bit 7 6 5 4 3 2 1 0 WCMP Access R W R W Reset 0 0 Bit 1 WCMP Window Comparator Interrupt Flag This window comparator flag is set when the measurement is complete and if the result matches the selected Window Comparator mode defined by the WINCM bit field in the Control E ADCn CTRLE regi...

Страница 14: ... This bit field constitutes the high byte of the ADCn RES register where the MSb is RES 15 Bits 7 0 RES 7 0 Result Low Byte This bit field constitutes the low byte of the ADCn RES register RES 15 8 RES 7 0 Read the RES register and shift the result 4 bits to compensate for the 16 oversamples uint16_t result ADC0 RES 4 TB3287 Measuring VDDIO2 2020 Microchip Technology Inc Technical Brief DS90003287...

Страница 15: ...figure below If a different LED is used the resistor value needs to change This is calculated using the following formula where VLED is the voltage drop of the LED and ALED is current through the LED 2 WARNING The AVR DB can not be programmed below 2V so to ensure proper operation set VDD to 3 3V by dragging and dropping the provided text file VDD3V3 txt onto the CURIOSITY drive on your PC When pr...

Страница 16: ...N0_bm Toggle LED pin void LED_PC0_toggle void PORTC OUTTGL PIN0_bm int main void LED_PC0_init while 1 Check if VDDIO2 is within acceptable range if MVIO STATUS MVIO_VDDIO2S_bm Blink LED at PC0 forever while 1 LED_PC0_toggle _delay_ms 250 The code for this example is available in the blinking a 3v0 led with vdd at 1v8 folder in these github repositories TB3287 Blinking a 3V LED with VDD at 1 8V 202...

Страница 17: ...8 product page www microchip com DevelopmentTools ProductDetails PartNO EV35L43A 4 AVR128DB48 Curiosity Nano User Guide www microchip com DS50003037 5 Curiosity Nano AVR128DB48 Schematics ww1 microchip com downloads en DeviceDoc AVR128DB48_Curiosity_Nano_Schematics pdf TB3287 References 2020 Microchip Technology Inc Technical Brief DS90003287A page 17 ...

Страница 18: ...9 Revision History Doc Rev Date Comments A 09 2020 Initial document release TB3287 Revision History 2020 Microchip Technology Inc Technical Brief DS90003287A page 18 ...

Страница 19: ...void PORTF DIRSET PIN5_bm void LED0_toggle void PORTF OUTTGL PIN5_bm int main void Enable the VDDIO2 interrupt MVIO INTCTRL MVIO_VDDIO2IE_bm Enable Global interrupts sei LED0_init Replace with your application code while 1 ISR MVIO_MVIO_vect The VDDIO2 interrupt has been triggered LED0_toggle Clear the CFD interrupt flag MVIO INTFLAGS MVIO_VDDIO2IF_bm Example 10 3 Measuring VDDIO2 define F_CPU 400...

Страница 20: ...e 16 oversamples uint16_t result ADC0 RES 4 return result int main void adc0_init Replace with your application code while 1 Read the VDDIO2 voltage continiously read_VDDIO2 Example 10 4 Blink a 3V LED with VDD at 1 8V define F_CPU 4000000ul include avr io h include util delay h void LED_PC0_init void PORTC DIRSET PIN0_bm void LED_PC0_toggle void PORTC OUTTGL PIN0_bm int main void LED_PC0_init whi...

Страница 21: ... TB3287 Appendix 2020 Microchip Technology Inc Technical Brief DS90003287A page 21 ...

Страница 22: ...stomers A listing of sales offices and locations is included in this document Technical support is available through the website at www microchip com support Microchip Devices Code Protection Feature Note the following details of the code protection feature on Microchip devices Microchip products meet the specifications contained in their particular Microchip Data Sheet Microchip believes that its...

Страница 23: ...T logo MPLAB OptoLyzer PackeTime PIC picoPower PICSTART PIC32 logo PolarFire Prochip Designer QTouch SAM BA SenGenuity SpyNIC SST SST Logo SuperFlash Symmetricom SyncServer Tachyon TempTrackr TimeSource tinyAVR UNI O Vectron and XMEGA are registered trademarks of Microchip Technology Incorporated in the U S A and other countries APT ClockWorks The Embedded Control Solutions Company EtherSynch Flas...

Страница 24: ...Quality Management System For information regarding Microchip s Quality Management Systems please visit www microchip com quality TB3287 2020 Microchip Technology Inc Technical Brief DS90003287A page 24 ...

Страница 25: ...China Xiamen Tel 86 592 2388138 China Zhuhai Tel 86 756 3210040 India Bangalore Tel 91 80 3090 4444 India New Delhi Tel 91 11 4160 8631 India Pune Tel 91 20 4121 0141 Japan Osaka Tel 81 6 6152 7160 Japan Tokyo Tel 81 3 6880 3770 Korea Daegu Tel 82 53 744 4301 Korea Seoul Tel 82 2 554 7200 Malaysia Kuala Lumpur Tel 60 3 7651 7906 Malaysia Penang Tel 60 4 227 8870 Philippines Manila Tel 63 2 634 906...

Отзывы: