void gpib_init() //chip initialization
{
outp(5,0X02); //chip reset
outp(5,0X2A); //set clock 20MHz
outp(5,0X50); //page_in
outp(3,0X80); //set ICR2
outp(4,0X31); //set ADMR
outp(6,0X2F); //set gpib address is 15
outp(6,0XCF);
outp(3,0X00); //initial serial poll response
outp(5,0XE0); //initial parallel response
outp(5,0XB4);
outp(5,0X4B);
outp(5,0X8C);
outp(1,0X13); //interrupt enable
outp(2,0X40);
outp(5,0X00); //pon
}
void intr _INT3Interrupt(void) //INT3
{
IEC3bits.INT3IE=0;
IFS3bits.INT3IF=0;
nStatus=inp(0); //read ISR0
if(nStatus&0X80)
{
if(inp(1)&0X04)
{
MyStatus=inp(2);
if(MyStatus&0X02) //talker,set state
{
bListen=0;
bTalk=1;
}
if(MyStatus&0X04) //listener,set state
{
bListen=1;
bTalk=0;
}
}
}
if((nStatus&0X20)&&(bListen==1)) //receive new data
{
DataRcv=inp(7);
pdtem_r[nRCount++]=DataRcv; //take data to buffer
outp(3,0X02); // complete receiving data
}
if((nStatus&0X10)&&(bTalk==1)) //last data sending completly
{
if(!bSndOver) //buffer is blank or not
{
DataSnd=remote[nSCount++];
//if(nSCount==nSNumber)
if(remote[nSCount]==0X0A)
{
outp(3,0X08); //send EOI
bSndOver=1; //send completly
}
outp(7,DataSnd); //send next data
}
}
if(nStatus&0X80)
{
bRecOver=1; //receive the string of data completly,set state
}
if(nStatus&0X04)
{
outp(5,0X40);
}
IEC3bits.INT3IE=1;
IFS3bits.INT3IF=0;
}
I use the NAT7210 which is controlled by MCU.
This is my program,after gpib_init( ), the level of the pin 11 is low all along.
But I think it should be high.
And I think, if there is data which is transmitted to NAT7210 from PC, the IC should generate an interruption and the level of the pin 11 should be changed from high to low,
and immediately it will be from low to high.
If it is from high to low, my MCU will go to INT3Interrupt.
But no interruption is generated when data is transmitted.
Please give me a help and check if my codes is correct.
Thanks!