lpc2148 –dac - weebly · lpc2148 –dac department of eie / pec dr.r.sundaramurthy., m.e.,ph.d.,...

Post on 20-May-2020

6 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

LPC2148 –DAC

Dr.R.Sundaramurthy.,M.E.,Ph.D., sundar@pec.eduDepartment of EIE / PEC

Dr.R.SundaramurthyDepartment of EIE

Pondicherry Engineering College

sundar@pec.edu

ADC

• 10 bit digital to analog converter

• Resistor string architecture

• Buffered output

• Power-down mode

Dr.R.Sundaramurthy.,M.E.,Ph.D., sundar@pec.eduDepartment of EIE / PEC

• Power-down mode

• Selectable speed vs. power

PLL

Dr.R.Sundaramurthy.,M.E.,Ph.D., sundar@pec.eduDepartment of EIE / PEC

VPBDIV = 0x00000001;

Pins InvolvedDAC

ADC0.4 [Pin 9] P0.25

p

o

t

Dr.R.Sundaramurthy.,M.E.,Ph.D., sundar@pec.eduDepartment of EIE / PEC

ADC

Dr.R.Sundaramurthy.,M.E.,Ph.D., sundar@pec.eduDepartment of EIE / PEC

AD0.4 / AOUT

SFRs Involved

• VLSI Peripheral Bus Divider - VPBDIV

• P0 Pin Select Register - PINSEL1

• DAC Control Register - DACR

Dr.R.Sundaramurthy.,M.E.,Ph.D., sundar@pec.eduDepartment of EIE / PEC

Pin Select SFRs

• PINSEL0 for GPIO pins 0.0 to 0.15

• PINSEL1 for GPIO pins 0.16 to 0.31

• PINSEL2 for GPIO pins 1.16 to 1.31

Dr.R.Sundaramurthy.,M.E.,Ph.D., sundar@pec.eduDepartment of EIE / PEC

Each Pin is Associated with multiple functions

Pin Select enable you to select which pin

functions you would like to use

How to Use PINSEL

• Each associated 'pin' in PINSEL is assigned a

2-bit address.

Dr.R.Sundaramurthy.,M.E.,Ph.D., sundar@pec.eduDepartment of EIE / PEC

PINSEL1 = PINSEL1 | 2 << (25-16) * 2

DAC Control Register - DACR

Dr.R.Sundaramurthy.,M.E.,Ph.D., sundar@pec.eduDepartment of EIE / PEC

void sendDAC(unsigned int DACdata)

{

pinselect(0,25,2);

DACR = DACdata << 6;

}

void GenerateSine()

{

// 100 samples

// 1 KHz

// T= 1ms / 100 samples = 10micro

Dr.R.Sundaramurthy.,M.E.,Ph.D., sundar@pec.eduDepartment of EIE / PEC

// T= 1ms / 100 samples = 10micro

unsigned int sinedata[10] =

{1,2,3,4,5,6,7,8,9,10} ;

int i;

for(i=0;i<10;i++)

{

sendDAC(sinedata[i]);

delayus(10);

}

}

pinselectvoid pinselect(int portnumber,int pinnumber, int functionselect)

{

if (portnumber == 0)

{

if (pinnumber >= 0 && pinnumber <= 15 )

PINSEL0 |= functionselect << (pinnumber * 2 ) ;

if (pinnumber >= 16 && pinnumber <= 31 )

PINSEL1 |= functionselect << ((pinnumber - 16) * 2 ) ;

}

Dr.R.Sundaramurthy.,M.E.,Ph.D., sundar@pec.eduDepartment of EIE / PEC

}

else if (portnumber == 1)

{

if (pinnumber >= 16 && pinnumber <= 31 )

PINSEL2 |= functionselect << ((pinnumber - 16) * 2 ) ;

}

else

portnumber = 3; // Dummy Write }

End of Session

Dr.R.Sundaramurthy.,M.E.,Ph.D., sundar@pec.eduDepartment of EIE / PEC

sundar@pec.edu

top related