Interfacing: DAC for waveform generation

Updated on 2017/06/19 21:10

Syllabus

Interfacing the peripherals to LPC2148: on-chip DAC for waveform generation.

Features of DAC

  • LPC2148 has one 10-bit DAC
  • Settling time software selectable 
  • DAC output can drive max of 700 A or 350 A 
  • DAC peripheral has only one register, DACR 
  • It contains 10-bit value for conversion in bit[15:6] position 
  • Bit[16] selects settling time, ‘1’ selects 700 s, ‘0’ selects 350 s 
DAC Pin Description 
PinTypeDescription
AOUTOutputAnalog Output. After the selected settling time after the DACR is written with a new value, the voltage on this pin (with respect to VSSA) is VALUE/1024 * VREF.
VREFReferenceVoltage Reference. This pin provides a voltage reference level for the D/A converter.
VDDA, VSSAPowerAnalog Power and Ground. These should be nominally the same voltages as V3 and VSSD, but should be isolated to minimize noise and error.

Digital to Analog Control Register (DACR)

31-171615-65-0
ReservedBIAS10-bit Digital ValueReserved
DAC Register (DACR - address OxE006 C000) Bit Description 
BitSymbolValueDescriptionReset value
5:0- Reserved, user software should not write ones to reserved NA bits. The value read from a reserved bit is not defined.NA
15:6VALUE After the selected settling time after this field is written with a 0 new VALUE, the voltage on the AOUT pin (with respect to VssA) is VALUE/1024 * VREF.0
16BIAS0The settling time of the DAC is 1 µs max, and the maximum 0 current is 700 µA.0
1The settling time of the DAC is 2.5 µs and the maximum current is 350 µA. 
31:17- Reserved, user software should not write ones to reserved NA bits. The value read from a reserved bit is not defined.NA

Example:
Configure DAC register for generating with 3.3V VREF & Select 700 microseconds settling time.

  1. 0V,
  2. 1.65V,
  3. 3.3V 

Formula:

AOUT= VREF * (10 bit Digital Value/Resolution)

Solution:

  1. DACR = 0x00010000;     //AOUT = 0V
  2. DACR  =  0x00018000;     //AOUT = 1.65V
  3. DACR = 0x0001FFC0;      //AOUT = 3.3 V

Draw DAC interfacing diagram with LPC2148. Also write program for triangular waveform generation

Interfacing Diagram

dac_interfacing.png

Configuring internal DAC of LPC2148 for Generation of Triangular waveform

Embedded C Program

#include"LPC214x.h"
#define DACPinMask 1 << 19
#define DAC_DataMask 0x0000FFC0
#define DataShift 6
void DACInit(void)
{
int i;
i = PINSEL1;
i = (i & 0xFFF3FFFF ); //Set P0.25 as AOUT Pin for analog output
PINSEL1 = (i | DACPinMask);
DACR = 1 << 16 ;    //set the settling time to 2.5us and max current to 300uA
}
void delay(unsigned int time)
{
unsigned int i,j;
for(i = 0; i < time ;i++ )
 {
for(j = 0; j < 10000 ; j++);
 }
}

int main(void)
{
int i;
  DACInit();      // initialsie the DAC interface
while(1)
 {
 for(i = 0 ; i < 1024 ;i++ )  // positive ramp of triangular waveform
 {
    DACR = ( DAC_DataMask & (i << DataShift));
    delay(2);
  }
 for(i = 1023 ; i > 0 ;i-- )  //negative ramp of triangular waveform
 {
    DACR = ( DAC_DataMask & (i << DataShift));
    delay(2);
  }
 }
return 0;
}

References

  • WikiNote Foundation
  • Prof. Sujit Wagh
Tags:
Created by XWikiGuest on 2017/04/14 13:07