ADC Programming: Va (Vref/2) Dval
ADC Programming: Va (Vref/2) Dval
Va = ( Vref/212 )* Dval
Successive Approximation
ADC Registers
Register Description
ADCR A/D COntrol Register: Used for
Configuring the ADC
ADGDR A/D Global Data Register: This register
contains the ADC’s DONE bit and the
result of the most recent A/D conversion
ADINTEN A/D Interrupt Enable Register
ADDR0 - ADDR7 A/D Channel Data Register: Contains the
recent ADC value for respective channel
ADSTAT A/D Status Register: Contains DONE &
OVERRUN flag for all the ADC channels
ADCR – A/D Control Register :
• Bits[7:0] – SEL: Bit ‘x'(in this group) is used to select AD0.x
• Bits[15:8] – CLKDIV: ADC Peripheral clock i.e. PCLK_ADC0 is
divided by CLKDIV+1 to get the ADC clock.
• Bit[16] – BURST: Set to 1 for doing repeated conversions, else 0
for software controlled conversions. Note: START bits must be set
to 000 when BURST=1 or conversions will not start. The
conversion is started scanning through the pins selected by bits
set to ones in the SEL field. The first conversion corresponds to
the least-significant 1 in the SEL field, then higher numbered 1-
bits. Repeated conversions can be terminated by clearing this bit,
but the conversion that’s in progress when this bit is cleared will
be completed. If BURST is set to 1, the ADGINTEN bit in the
ADINTEN register must be set to 0.
• Bit[21] – PDN : Set it to 1 for powering up the ADC and
making it operational. Set it to 0 for bringing it in power down
mode.
• Bits[26:24] – START: These bits are used to control the start of
ADC conversion when BURST (bit 16) is set to 0. 000 = No
start, 001 = Start the conversion.
• Bit[27] – EDGE: Set this bit to 1 to start the conversion on
falling edge of the selected CAP/MAT signal and set this bit to
0 to start the conversion on rising edge of the selected signal.
(Note: This bit is of used only in the case when the START
contains a value between 010 to 111 as shown above.)
• Other bits are reserved
ADGDR – A/D Global Data Register : Contains the ADC’s flags and the
result of the most recent A/D conversion.
• Bits[15:4] – RESULT: When DONE bit = 1, these bits give a binary
fraction which represents the voltage on the pin AD0.x. Value of 0x0
indicates that voltage on the given pin was less than, equal to or
greater than VREFN. And a value of 0xFFF means that the input voltage
was close to, equal to or greater than the VREFP.
• Bits[26:24] – CHN: Represents the channel from which RESULT bits
were converted. 000= channel 0, 001= channel 1 and so on.
• Bit[30] – OVERRUN: In burst mode this bit is 1 in case of an Overrun
i.e. the result of previous conversion being lost(overwritten). This bit
will be cleared after reading ADGDR.
• Bit[31] – DONE: When ADC conversion completes this bit is 1. When
this register(ADGDR) is read and ADCR is written, this bit gets cleared
i.e. set to 0. If ADCR is written while a conversion is in progress then
this bit is set and a new conversion is started.
• Other bits are reserved.
ADDR0 to ADDR7 – A/D Data registers : This register contains
the result of the most recent conversion completed on the
corresponding channel [0 to 7]. Its structure is same as ADGDR
except Bits[26:24] are not used/reserved.
Ref:
http://www.ocfreaks.com/lpc1768-adc-programming-tutorial/
https://www.exploreembedded.com/wiki/LPC1768:_ADC_Programming
Chapter 29 of User Manual (UM10360_LPC176x)
Nested Vector Interrupt Control (NVIC)
Ref:
https://www.motioncontroltips.com/what-is-nested-vector-interrupt-control-nvic/
EXTERNAL INTERRUPTS
https://www.exploreembedded.com/wiki/LPC1768:_External_Interrupts