On Chip ADC Interfacing: Experiment No.6
On Chip ADC Interfacing: Experiment No.6
On Chip ADC Interfacing: Experiment No.6
Experiment No.6
Components:
Educational practice board for ARM7 LPC2148
All in one general purpose board (ASK25)
+9V power supply
USB A to B type cable
20 pin flat cable
Single lead wire
PC
Eclipse IDE
Flash Magic Utility
Connections:
Note: Make sure the following header files are included in the project:
Included Files:
The EPBARM7 has 4 pin FRC connector which brings out the ADC signals.
ADGDR:
A/D Global Data Register. This register contains the ADC’s DONE bit and the result of the
most recent A/D conversion.
Bit Description
0:5 Reserved, user software should not write ones to reserved bits. The value read from
a reserved bit is not defined.
15:6 When DONE is 1, this field contains a binary fraction representing the voltage on the
Ain pin selected by the SEL field, divided by the voltage on the VDDA pin (V/VREF).
Zero in the field indicates that the voltage on the Ain pin was less than, equal to, or close
to that on VSSA, while0x3FF indicates that the voltage on Ain was close to, equal to, or
greater than that on VREF
.
23:16 Reserved, user software should not write ones to reserved bits. The value read from
a reserved bit is not defined.
26:24 These bits contain the channel from which the RESULT bits were converted
29:27 Reserved, user software should not write ones to reserved bits. The value read from
a reserved bit is not defined.
30 This bit is 1 in burst mode if the results of one or more conversions was (were) lost
and overwritten before the conversion that produced the result in the RESULT bits.
This bit is cleared by reading this register.
31 This bit is set to 1 when an A/D conversion completes. It is cleared when this register is
read and when the ADCR is written. If the ADCR is written while a conversion is still in
progress, this bit is set and a new conversion is started.
ADGSR: A/D Global Start Register. This address can be written (in the AD0 address range) to
start conversions in both A/D converters simultaneously.
26:24 START 000 No start (this value should be used when clearing PDN to 0)
001 Start conversion now
010 Start conversion when the edge selected by bit 27 occurs on
P0.16/EINT0/MAT0.2/CAP0.2 pin
ADDR0: The A/D Data Register holds the result when an A/D conversion is complete, and also
includes the flags that indicate when a conversion has been completed and when a conversion
overrun has occurred.
15:6 RESULT When DONE is 1, this field contains a binary fraction representing the
voltage on the AIN pin, divided by the voltage on the VREFpin
(V/VREF).Zero in the field indicates that the voltage on the AIN pin was
less than, equal to, or close to that on VSSA while 0x3FF indicates that
thevoltage on AIN was close to, equal to, or greater than that on VREF.
29:16 - Reserved, user software should not write ones to reserved bits. The value
read from a reserved bit is not defined.
30 OVERUN This bit is 1 in burst mode if the results of one or more conversions was
(were) lost and overwritten before the conversion that produced the result in
the RESULT bits.This bit is cleared by reading this register
31 DONE This bit is set to 1 when an A/D conversion completes. It is cleared when
this register is read
Sample Algorithm:
1. Initialise LCD.
2. Write string to LCD.
3. Display channel number.
4. Configure timer mode T0CTCR = 0X00.
5. T0PC = 0, Prescalar counter is set to 0.
6. T0pr = 0XF0, Prescalar is set to hex value of 240 so 12 Mhz/240 = 50000
7. T0mr0 = 0x350, The match register values are continuously compared to the timer
counter value. When the two values are equal enable reload thr’ match control register.
8. T0MCR = 0X3, Interrupt on match and reset timer.
9. T0TCR = 1, Enable timer again.
10. VIC Int Enable |=(0X01 << 4) Enable interrupt corresponding to timer 0(bit 4 is
dedicated to timer 0 interrupt).
11. VIC VectAddr0 = unsigned timer0_routine, return the address for interrupt service
routine.
12. VIC Vect Cntl0 = (0X24).
13. Enable interrupt.
Result:
ADC values would be displayed on LCD. Values will change every one second as you rotate
potentiometer RV3.Note hex output on LCD for 4 different positions of potenciometer.Also
measure same analog input with multimeter.
Questions: