Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

TNT4882 wrong data read from FIFO running test programm

Hello,

I am new for GPIB and I start from test from "Using the TNT4882 in an 8051-Family Microcontroller-Based System". We use AT32UC3A microcontroller and I rewrite test in C. FIFOA and FIFOB test running without error. When programm test NFF and NEF interrupts I receive error. Debugging show that both interrupts work fine, there is error reading data from FIFOB (test programm request NFF interrupt and interrupt handler push 2 bytes to FIFOB. then test request NEF and handler read 2 bytes from FIFOB). Programm push 0x55 and 0xaa, hadler read 0xf2 0xaa. I try different things - nothing change, finally I push 3 bytes to FIFOB - dummy 0x50, then 0x55 and 0xaa. this time I read correct 2 bytes in handler - 0x55 and 0x55. Please note that just before interrupt test FIFOA and FIFOB was tested writing -reading with data range0-255 without error. There is a source code of the interrupt test (I leave original procedures descriptions from app note):


//************************************************************************//
//* Module : INT_TST *//
//* Description : Performs Interrupt Test. *//
//* *//
//* Reference : MCS51 & TNT4882 Application Notes. *//
//************************************************************************//
//************************************************************************//
unsigned char int_tst_4882(void)
{
unsigned char i;

    errorTNT=0;

    printString("waiting for NFF interrupt...", 50, 220, GREEN, (U8 *)&pfont[0]);
    tnt[(IMR3<<2)| BASE]=0x08;        //Write interrupt bit NFF to interrupt register
    //wait until it become 0
    do{i=tnt[(IMR3<<2)| BASE];}while((i&0x08)!=0);
    printString("waiting for NEF interrupt...", 50, 230, GREEN, (U8 *)&pfont[0]);
    tnt[(IMR3<<2)| BASE]=0x04;        //Write interrupt bit NEF to interrupt register
    do{i=tnt[(IMR3<<2)| BASE];}while((i&0x04)!=0);

    return(errorTNT);
}
//************************************************************************//
//************************************************************************//
//* Module : HANDLER *//
//* Parameters : NONE *//
//* Description : Interrupt Handler. This routine is entered when the *//
//* TNT chip asserts its interrupt signal. The interrupts*//
//* should be enabled for interrupts to occur. *//
//* The handler handles two cases of interrupts. These *//
//* cases are INPUT, and OUTPUT. *//
//************************************************************************//
//************************************************************************//
//==================================================================================================================
//interrupt.
//in this procedure we will handle interrupt from TNT4882
//X-Y coordinates of the touch panel
__attribute__((__interrupt__))
static void gpio_pb28_int(void)
{
unsigned char i,a;


    //printString("Interrupt active", 50, 210, GREEN, (U8 *)&pfont[0]);
    i=tnt[(IMR3<<2)| BASE];
    a=tnt[(ISR3<<2)| BASE];
    if ((i & a & 0x08)!=0x08)
        { //maybe NEF?
        if ((i & a & 0x04)!=0x04)
              {
              errorTNT=1;
              goto intend;
              }
        i=i & 0xFB;    //reset NFF flag and put it back
        tnt[(IMR3<<2)| BASE]=i;
        //read data from FIFOB

        a = tnt[(FIFOB<<2)| BASE];        //Read $55 from FIFOB
        i = tnt[(FIFOB<<2)| BASE];        //Read $AA from FIFOB
        if (a!=0x55 || i!=0xaa)
            {
            errorTNT=1;
            goto intend;
            }
        }
    else    //NFF
        {
        i = i & a & 0xF7;    //reset NFF flag and put it back
        tnt[(IMR3<<2)| BASE]=i;

        tnt[(CMDR<<2) | BASE]=0x10; //Reset FIFOs
        //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!/DUMMY WRITE FOR UNKNOW REASONS
        tnt[(FIFOB<<2)| BASE]=0x50;        //DUMMY WRITE FOR UNKNOW REASONS

        tnt[(FIFOB<<2)| BASE]=0x55;        //Write $55 to FIFOB
        tnt[(FIFOB<<2)| BASE]=0xaa;        //Write $AA to FIFOB
        }
intend:
        gpio_clear_pin_interrupt_flag(GPIO_PIN_INT);   //Reset INT state of the input pin
}

 

May be someone can explain what and why happen - why I did not read original data and should write "dummy" byte?

 

Thank you very much in advance for  your help and support!

0 Kudos
Message 1 of 3
(3,380 Views)
0 Kudos
Message 2 of 3
(3,377 Views)

Thank you very much for your reply and note. I did not find answer to my question until now. May be you can give me more specific direction?
Thank you very much in advance for your answer!

0 Kudos
Message 3 of 3
(3,327 Views)