26
1 NuMicro ADC [email protected]

09_NuMicro ADC.pdf

Embed Size (px)

DESCRIPTION

tes

Citation preview

Page 1: 09_NuMicro ADC.pdf

1

NuMicro ADC

[email protected]

Page 2: 09_NuMicro ADC.pdf

2

Agenda

FeaturesADC Block DiagramADC Function DescriptionsADC Operation ModesADC Operation Flow and Sample Code

Page 3: 09_NuMicro ADC.pdf

3

Features

Page 4: 09_NuMicro ADC.pdf

4

ADC General Features (I)

12-bit SAR ADCAnalog input voltage range:

0~Vref (Max to 5.0V).

Operation voltage: AVDD=3.0V~5.5V;

Input channel:Up to 8 single-end analog input channels

4 pairs of differential analog input channel.

Up to 600KHz

conversion rate.The maximum ADC operating frequency is 16M HzThree operation modes

Single mode

Single-cycle modeContinuous scan mode

Page 5: 09_NuMicro ADC.pdf

5

ADC General Features (II)

An A/D conversion can be started bySoftware triggerExternal trigger pin (STADC pin)

Conversion results are held in data registers for each channel with VALID and OVERRUN indicators.The ADC equips with a digital compare function. User can use this function to monitor the conversion result of a user-specific channel.Channel 7 support 3 input sources:

external analog voltage internal bandgap

voltage

output of internal temperature sensor

Support Self-calibration to minimize the conversion error.

Page 6: 09_NuMicro ADC.pdf

6

ADC Block Diagram

Page 7: 09_NuMicro ADC.pdf

7

Conversion Results

ADC Configuration Control

Channel Selection

External Trigger Pin4 options: falling/rising /high/low

Reference Voltage Input

ADC PDMA Request

ADC Interrupt Request

Page 8: 09_NuMicro ADC.pdf

8

ADC Function Descriptions

Page 9: 09_NuMicro ADC.pdf

9

ADC Register Map

Register Offset R/W Description Reset Value

ADC_BA = 0x400E_0000

ADDR0 ADC_BA+0x00 R A/D Data Register 0 0x0000_0000

ADDR1 ADC_BA+0x04 R A/D Data Register 1 0x0000_0000

ADDR2 ADC_BA+0x08 R A/D Data Register 2 0x0000_0000

ADDR3 ADC_BA+0x0C R A/D Data Register 3 0x0000_0000

ADDR4 ADC_BA+0x10 R A/D Data Register 4 0x0000_0000

ADDR5 ADC_BA+0x14 R A/D Data Register 5 0x0000_0000

ADDR6 ADC_BA+0x18 R A/D Data Register 6 0x0000_0000

ADDR7 ADC_BA+0x1C R A/D Data Register 7 0x0000_0000

ADCR ADC_BA+0x20 R/W A/D Control Register 0x0000_0000

ADCHER ADC_BA+0x24 R/W A/D Channel Enable Register 0x0000_0000

ADCMPR0 ADC_BA+0x28 R/W A/D Compare Register 0 0x0000_0000

ADCMPR1 ADC_BA+0x2C R/W A/D Compare Register 1 0x0000_0000

ADSR ADC_BA+0x30 R/W A/D Status Register 0x0000_0000

ADCALR ADC_BA+0x34 R/W A/D Calibration Register 0x0000_0000

ADPDMA ADC_BA+0x40 R/W ADC PDMA current transfer data 0x0000_0000

Page 10: 09_NuMicro ADC.pdf

10

ADC Clock Source

The maximum ADC clock frequency is 16MHzThe ADC clock frequency = (ADC clock source frequency) / (ADC_N+1); ADC_N is an 8-bit pre-scaler

Page 11: 09_NuMicro ADC.pdf

11

ADC Input Channel Setting

The ADC input pins share with GPIO port AThe ADC input pins must be configured in input typeSingle-end input mode

Channel 0 ~ Channel 7 share with GPA0~GPA7Differential input mode

Channel 0 ~ Channel 3Differential input channels are the paired channels of single-end input channels

Differential input paired channel

Single-end input channel

0 0 1

1 2 3

2 4 5

3 6 7

Page 12: 09_NuMicro ADC.pdf

12

Self-Calibration

User can write 1 to CALEN bit in ADCALR register to enable the self calibration function. The CAL_DONE bit reflects the calibration state.

The timing of self-calibrationAfter power onAfter switching input mode between single-end and differential

Page 13: 09_NuMicro ADC.pdf

13

Result Monitor Function

Two digital comparators. Compare the ADC result of the specified channel with a user defined compare value stored in CMPD(ADCCMPRx[27:16]) When the conversion of the channel specified by CMPCH is completed, the comparing action will be triggered automatically.

Page 14: 09_NuMicro ADC.pdf

14

ADC Interrupt

Three interrupt sourcesADF: completion of a ADC operation modeCMPF0: Condition match monitored by ADC comparator0CMPF1: Condition match monitored by ADC comparator1

Page 15: 09_NuMicro ADC.pdf

15

ADC Operation Modes

Page 16: 09_NuMicro ADC.pdf

16

Single Mode

A/D conversion is to be performed only once on the specified single channel.If software enables more than one channel in single mode, only the lowest channel

will be

converted and the other enabled channels will be ignored.

Page 17: 09_NuMicro ADC.pdf

17

Single-Cycle Scan Mode

3'b000 3'b010 3'b011 3'b111

sample

ADST

chsel[2:0]

SAR[11:0]

ADDR0

ADDR2

ADDR3

ADDR7

Single-cycle scan on channel 0, 2, 3 and 7 (ADCHER[7:0] = 8'b10001101)

R0 R2 R3 R7

R0

R2

R3

R7

Channel0 Channel2 Channel3 Channel7

Page 18: 09_NuMicro ADC.pdf

18

Continuous Scan Mode

3'b000 3'b010 3'b011 3'b111 3'b000 3'b010 3'b011 3'b111 3'b010

ADDR7

ADDR3

ADDR2

ADDR0

sample

chsel[2:0]

ADST

Continuous scan on channel 0, 2, 3, and 7 (ADCHER[7:0] = 8'b10001101)

Software clear ADST

Channel0 Channel2 Channel3 Channel7 Channel0 Channel2

Page 19: 09_NuMicro ADC.pdf

19

ADC operation flow

Page 20: 09_NuMicro ADC.pdf

20

Step 1

Step 2

Step 3

Step 4

Step 5

Step 7

Step 6

Page 21: 09_NuMicro ADC.pdf

21

/*----------------------------------------------------------------------------MAIN function----------------------------------------------------------------------------*/int32_t main (void){

/* Step 1. GPIO initial *///Set input mode GPIOA->PMD.PMD1=0;//Disable digital input pathGPIOA->SCH|=0x00020000;//Set ADC functionSYS->GPAMFP.ADC1=1;

/* Step 2. Enable and Select ADC clock source, and then enable ADC module */ //Select 22Mhz for ADCSYSCLK->CLKSEL1.ADC_S = 2;//ADC clock source = 22Mhz/2 =11Mhz;SYSCLK->CLKDIV.ADC_N = 1;//Enable clock sourceSYSCLK->APBCLK.ADC_EN = 1;

/* Step 3. Select Operation mode *///Enable ADC moduleADC->ADCR.ADEN = 1;//Single end inputADC->ADCR.DIFF = 0;//Single modeADC->ADCR.ADMD = 0;

Sample Code(1/2)

Page 22: 09_NuMicro ADC.pdf

22

/* Step 4. Select ADC channel */ADC->ADCHER.CHEN = 0x02;

/* Step 5. Enable ADC interrupt *///clear the A/D interrupt flags for safe ADC->ADSR.ADF =1; ADC->ADCR.ADIE = 1;// To enable the ADC interrtuptNVIC_EnableIRQ(ADC_IRQn);

/* Step 6. Conversion start */ADC->ADCR.ADST=1;/* Step 7. wait ADC interrupt */while(1){

if (ADC_INT_FLAG==0) break;

}}

Sample Code(2/2)

Page 23: 09_NuMicro ADC.pdf

23

ConditionADC

Input channel:ADC7Clock source: 11MHz (22MHz/2)Operation mode: Single mode

PWMOutput Channel:PWM0Clock source: 0.66Hz (22.1184MHz/((255+1)*2)/(65535+1))PWM duty is defined by ADC value

LCDDisplay ADC value

Page 24: 09_NuMicro ADC.pdf

24

ADC+PWM Block DiagramBlock Diagram

NUC140V3AN

ADC7

Cortex-M0

Flash

VCC

VR120KADC

GP

A7

ADC Value: 277

LCD PanelPWM0

LED

SPI

Page 25: 09_NuMicro ADC.pdf

25

Run Run ““Smpl_ADC_PWM”” CodeCode

Customer_CDCustomer_CD Readme.txtReadme.txt

NUC1xx BSPDriver Reference GuideNUC1xx BSPDriver Reference GuideNUC1xx_BSP

NuvotonPlatform_Keil

NUC1xx-LB_002

Sample

Smpl_DrvADC_PWM. uvprojSmpl_DrvADC_PWM. uvprojSmpl_ADC_PWM

Page 26: 09_NuMicro ADC.pdf

26

Thank you