Professional Documents
Culture Documents
#include
#include
#include
#include
<iolpc2378.h>
"irq.h"
"config.h"
"dac.h"
*/
while ( 1 )
{
DACR = (i << 6) | DAC_BIAS;
i++;
if ( i == 1024 )
{
i = 0;
}
}
return 0;
}
17
Exp.No:
Date :
Aim
To interface ADC and DAC with ARM 7 Controller
Components Required:
1. LPC 2378 ARM Development board
2. IAR Embedded Workbench 6.5
3. Flash Magic ISP Utility
Theory
A digital-to-analog converter is a device for converting a digital (usually binary) code to
an analog signal (current, voltage or charges). Digital-to-Analog Converters are the interface
between the abstract digital world and the analog real life. Simple switches, a network of
resistors, current sources or capacitors may implement this conversion. A DAC inputs a binary
number and outputs an analog voltage or current signal.
MCP429x:
The Microchip Technology Inc. MCP492X is 2.7 5.5V, low-power, low DNL, 12-Bit
Digital-to-Analog Converters (DACs) with optional 2x buffered output and SPI interface. The
MCP492X are DACs that provide high accuracy and low noise performance for industrial
applications where calibration or compensation of signals is required
Interfacing SPI-DAC:
Fig.4 shows how to interface the SPI-DAC to microcontroller. With an SPI connection
there is always one master device (usually a microcontroller) which controls the peripheral
devices. Typically there are three lines common to all the devices,
Master In Slave Out (MISO) - The Slave line for sending data to the master,
Master Out Slave In (MOSI) - The Master line for sending data to the peripherals,
Serial Clock (SCK) - The clock pulses which synchronize data transmission generated by
the master.
Slave Select pin - the pin on each device that the master can use to enable and disable
specific devices.
18
OUTPUT:
19
Interfacing of ADC:
An analog-to-digital converter is a device that converts a continuous quantity to a
discrete digital number. Typically, an ADC is an electronic device that converts an input analog
voltage (or current) to a digital number proportional to the magnitude of the voltage or current.
The resolution of the converter indicates the number of discrete values it can produce over the
range of analog values. The values are usually stored electronically in binary form, so the
resolution is usually expressed in bits. In consequence, the number of discrete values available,
or "levels", is usually a power of two.
An ADC with a 10-bit output can represent up to 1024 (210) unique conditions of signal
measurement. Over the range of measurement from 0% to 100%, there will be exactly 1024
unique binary numbers output by the converter (from 0000000000 to 1111111111, inclusive).
ViARM - 2378 Development board has two potentiometers for working with A/D
Converter. All Potentiometers outputs are in the range of 0V to 3.3V. ARM processor takes
analog signal from its input pin and translates it into a digital value. Basically, you can measure
any analog signal that fits in range acceptable by LPC2378. That range is 0V to 3.3V.
PROCEDURE:
1. Run the Application IAR Embedded Workbench 6.5
2. Create new project in the current work space. Create a new project by selecting the tool
chain as ARM and create empty project and click ok. Give Project Name and click
SAVE Button.
3. Select LPC2378 >Options menu
4. Select General options category. Enable target option file and select the device as NXP
LPC2378 and click ok.
5. Select C/C++ Compiler >Select Preprocessor and include (C:\Program Files\IAR
Systems\Embedded
Workbench
6.5\arm\inc\c,
C:\Program
Files\IAR
Systems\Embedded Workbench 6.5\arm\inc\NXP)
6. Enable Output Converter Menu and select output format as Intel extended and Enable
Override default option
7. Select Linker Category. Enable Override default option, click SAVE Button.
8. New>File Menu, for creating a new C file. File>Save As, for saving a file. Give your
File name ( Eg: DAC.C) and click Save Button.
20
t1000,t100,t10,t1,temp;
/ 1000;
% 1000;
/ 100;
% 100;
/ 10;
% 10;
send_serial_data(t1000+0x30);
send_serial_data(t100 +0x30);
send_serial_data(t10+0x30);
send_serial_data(t1+0x30);
send_serial_data(0x0d);
send_serial_data(0x0a);
}
void main()
{
unsigned long int val;
unsigned int Fdiv;
TargetResetInit();
PCONP |= (1 << 12);
PINSEL1 = 0X00054000;
PINSEL0 = 0x00000050;
21
22
// AD0CR = 0x01200601;
// Start A/D Conversion
AD0CR = ( 0x01 << 1 ) |
/* SEL=1,select channel 0~7 on ADC0 */
( ( Fpclk / ADC_CLK - 1 ) << 8 ) | /* CLKDIV = Fpclk / 1000000 - 1 */
( 1 << 16 ) |
/* BURST = 0, no BURST, software controlled */
( 0 << 17 ) |
/* CLKS = 0, 11 clocks/10 bits */
( 1 << 21 ) |
/* PDN = 1, normal operation */
( 0 << 22 ) |
/* TEST1:0 = 00 */
( 1 << 24 ) |
/* START = 0 A/D conversion stops */
( 0 << 27 );
/* EDGE = 0 (CAP/MAT singal falling,trigger A/D
conversion) */
while(1)
{
while((AD0GDR & 0X80000000)!=0X80000000);
val = (AD0GDR>>6)& 0x3ff ;
// convesion data holds AD0DR0[6]
to AD0DR0[15]
adc_serial_tx(val);
// 10 bit adc data transmit serial
port.
}
}
23
RESULT:
24