LPC2148 –DAC
Dr.R.Sundaramurthy.,M.E.,Ph.D., [email protected] of EIE / PEC
Dr.R.SundaramurthyDepartment of EIE
Pondicherry Engineering College
ADC
• 10 bit digital to analog converter
• Resistor string architecture
• Buffered output
• Power-down mode
Dr.R.Sundaramurthy.,M.E.,Ph.D., [email protected] of EIE / PEC
• Power-down mode
• Selectable speed vs. power
Pins InvolvedDAC
ADC0.4 [Pin 9] P0.25
p
o
t
Dr.R.Sundaramurthy.,M.E.,Ph.D., [email protected] of EIE / PEC
SFRs Involved
• VLSI Peripheral Bus Divider - VPBDIV
• P0 Pin Select Register - PINSEL1
• DAC Control Register - DACR
Dr.R.Sundaramurthy.,M.E.,Ph.D., [email protected] 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., [email protected] 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., [email protected] of EIE / PEC
PINSEL1 = PINSEL1 | 2 << (25-16) * 2
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., [email protected] 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., [email protected] of EIE / PEC
}
else if (portnumber == 1)
{
if (pinnumber >= 16 && pinnumber <= 31 )
PINSEL2 |= functionselect << ((pinnumber - 16) * 2 ) ;
}
else
portnumber = 3; // Dummy Write }