Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

What is wrong about the interruption of my NAT7210?

Hello Steven T,
Thank you for your helping , I have solved the problem of DO interrupt by removing outp(3,0X00) and adding code to set GLINT, then my code runs successfully , but I do not understand why it is completely .Can you tell me the reason ?
Now , the other problem appears .
If PC sends command to NAT7210 , I can read LA and DI , then NAT7210 can receive the command successfully .
If PC reads NAT7210 , I can read TA and DO , then NAT7210 can send its command to PC successfully .
But when PC sends and reads commands with NAT7210 continuously , after a few commands are read and sent , I read that DO bit is set , but after NAT7210 sends some bytes , I read that ERR bit is set , according to page 5-8 of the manual , I change my code as following , but after executing the present code , communication of PC and NAT7210 is false still .
Is My solution right or wrong ?
Please help me check my code .
Thanks .


if((ADSR&0X02)==0X02) //TALKER
{
str_length=strlen(remote);
nStatus=inp(1); //read ISR1
if((nStatus&0X02)==0X02)
{
outp(0,remote[i]);
for(i=1;i {
while((nStatus&0X02)!=0x02)
{
nStatus=inp(1);
if((nStatus&0X04)==0x04) /ERR
{
outp(5,0X0E); //NBAF to clear CDOR
outp(5,0X57); //clear ERR bit
ERR=1;
i=str_length;
break;
}
}
if(!ERR) //if ERR , the spare byte is not send
{
outp(0,remote[i]);
nStatus=inp(1); //读中断状态寄存器ISR1
}
}
if(!ERR) //if ERR , the spare byte is not send
{
while((nStatus&0X02)!=0x02)
{
nStatus=inp(1);
}
outp(5,0X06); //send EOI
outp(0,remote[str_length-1]); //the last byte
}
}
}
0 Kudos
Message 11 of 13
(1,016 Views)
Hello Steven T, I am waiting for your help . Please reply as soon as possible. Thanks.
0 Kudos
Message 12 of 13
(978 Views)

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

0 Kudos
Message 13 of 13
(947 Views)