07-09-2010 04:41 AM
07-15-2010 07:21 PM
07-20-2010 04:40 AM
Hello Steven T,
I have read the manual several times . But sorry , I am not good at English , so I can not understand the manual completely .
My purpose is : let NAT7210 work as Listener and Talker automatically .
The follow is my code which is newest for initializing NAT7210 :
void gpib_init() //chip initialize
{
RESET=1;
delay(5);
RESET=0;
delay(5);
outp(3,0X99); //make sure NAT7210 work in 7210-mode
outp(5,0X02);
outp(5,0X50); //Page_in
outp(3,0X81); //ICR2
outp(5,0X2A); //ICR //set clock 20MHz
outp(4,0X31); //ADMR,
outp(6,0X0F); // address:15
outp(6,0XE0);
outp(5,0XE5); //AUXRI:USTD= 0,SISB=1,PP2=1
outp(5,0XAB); //AUXRB:ISS=0;TRI=0;INV=1:the INT pin is active low
//TRI=0 and USTD=0 : Source Handshake T1 delay,2000ns
outp(5,0X49); // AUXRG: CHES=1,NTNL=1
outp(5,0X9D); // AUXRA:HLDE=0,HLDA=1,XEOS=1,REOS=1
outp(5,0X50); //Page_in
outp(6,0X80); //IMR0:GLINT=1
outp(1,0X17); //IMR1
outp(2,0X68); //IMR2
outp(7,0X0A); // 0X0A
outp(5,0X00); //
}
After the initialization ,PC sends command to NAT7210 and let it as Listener, I can catch the interruption ,then I read ISR2 is 0X93 , ADSR is 0X54 , ISR1 is 0X01 , I check DI bit and read the command byte until 0X0A ; Then I send RHDF command to finish . The follow is my code for NAT7210 as Listener , please help me chaek it .
ADSC_INT=inp(2);
if((ADSC_INT&0X01)==0X01)
{
MyStatus=inp(4); // ADSR
if((MyStatus&0X04)==0X04) //as Listener
{
nStatus=inp(1); // ISR1
if((nStatus&0X01)==0X01)
{
pdtem_r[i]=inp(0);
while(pdtem_r[i]!=0x0a)
{
i++;
while((inp(1)&0X01)!=0x01);
pdtem_r[i]=inp(0);
}
outp(5,0X03);
nStatus=inp(1); // ISR1
while((nStatus&0X10)==0X10);
}
}
}
If PC send command to NAT7210 to let it as Talker , and let NAT7210 send data message , I also can catch the interruption ,then ISR2 is 0X81 , ADSR is 0X42 , ISR1 is 0X02 , then I wait for the DO bit to set and write the data byte to the CDOR .
The follow is my code for this segment ,but a few times of sending data successfully ,my code generate Bug ,at this time ,ISR2 is 0X93 , ADSR is 0X42 , ISR1 is 0X05 ,and NAT7210 can not send data to PC successfully .
I do not know how to resolve this matter , please teach me .
ADSC_INT=inp(2);
if((ADSC_INT&0X01)==0X01)
{
MyStatus=inp(4); // ADSR
if((MyStatus&0X02)==0X02)
{
str_length=strlen(remote);
i=0;
nStatus=inp(1); // ISR1
if((nStatus&0X02)==0X02)
{
outp(0,remote[i]);
nStatus=inp(1); // ISR1
while((nStatus&0X02)!=0x02)
{
nStatus=inp(1); // ISR1
}
for(i=1;i {
outp(0,remote[i]);
nStatus=inp(1); // ISR1
while((nStatus&0X02)!=0x02)
{ nStatus=inp(1); // ISR1
}
}
outp(5,0X06); // EOI
outp(0,remote[str_length-1]);
while((nStatus&0X02)!=0x02)
{
nStatus=inp(1); // ISR1
}
outp(5,0X03);
}
}
Thanks very much .
Fujun