Source Code
----------
#include
#include
#include
#include
#include
#define port 0x378 //data port 8pins 2,3,4,5,6,7,8,9
#define status 0x379 //status 5pins 11,10,12,13,15
#define control 0x37A //control 4pins 17,16,14,1
void main()
{
long int value;
int ch;
go:
clrscr();
//checkstatus();
cout<<"** AD9851 Programming with LPT1 **";
cout<<"\n----------------------------------";
cout<<"\n1. Send values to LPT";
cout<<"\n2. Set all data pins HIGH";
cout<<"\n3. Set all data pins LOW";
cout<<"\n4. Reset";
cout<<"\n5. Exit";
cout<<"\n Choose your entry :";
cin>>ch;
switch(ch)
{
case 1:
for(int i=0;i<5;i++)
{
cout<<"\nEnter W"<<<"=";>
cin>>value;
outport(port,value);
cout<<"\nValue"<
outport(control,0001); //clock high
cout<<"Setting Word Clock High!!!\n";
}
outport(control,0010); //freq update high
cout<<"Setting Frequency Update as HIGH !!!";
cout<<"Word Entered Successfully....";
getch();
goto go;
case 2:
outport(port,255);
cout<<"\n Setting all data pins to high...";
cout<<"\nPress any key to continue...";
getch();
goto go;
case 3:
outport(port,0);
cout<<"\n Setting all data pins to low...";
cout<<"\nPress any key to continue...";
getch();
goto go;
case 4:
outport(control,0011);
cout<<"\nResetting Complete...";
cout<<"\nPress any key to continue...";
getch();
goto go;
case 5: exit(0); break;
default : cout<<"\nWrong entry...";
}
}
void checkstatus()
{
unsigned int far *ptradr; /* Pointer to location of Port Addresses */
unsigned int address; /* Address of Port */
int a;
ptradr=(unsigned int far *)0x00000408;
for (a = 0; a <>
{
address = *ptradr;
if (address == 0)
printf("No port found for LPT%d \n",a+1);
else
printf("Address assigned to LPT%d is %Xh\n",a+1,address);
*ptradr++;
}
}
2 comments:
dey make it into proper HTML format before submitting Programming code into Blogs..
you must use the escape sequences whenever necessary..
You Must atleast use < for < and > for >
as these symbols define the tag boundry in HTML.
One easy way is to copy your program into Dream weaver design view and get the generated HTML code from the Code view.
Post a Comment