Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

NI TNT4882 -- problem with chip initalization

Using TNT4882 chip for GPIB support implementation and PIC18f6410 for control. Wrote following C code in MPLAB for TNT4882 initalization after power on:

void InitGPIB(void)
{
.
.
.
    //0. Hardware RESET
    LATCbits.LATC5 = 0; //TNT hardware reset
    LATFbits.LATF5 = 1; //set TNT startup mode to Turbo+7210/One-chip
    Nop();
    Nop();
    Nop();
    Nop();
    LATCbits.LATC5 = 1; //clear TNT reset state
    Nop();
    Nop();
    Nop();
    Nop();
    
    //1. Reset the Turbo488 Circuitry of the TNT4882
    WriteTNT(_T488_CMDR, SOFT_RESET);    //Comand Register = 0x22 - SOFT RESET
    
    //2. Place the TNT4882 in Turbo+7210 Mode -- not needed, TNT already in that mode
    //WriteTNT(0x06,0x80);
    //WriteTNT(0x0a,0x80);
    //WriteTNT(0x06,0x99);
    //WriteTNT(0x0a,0x99);
    
    //3. Configure the TNT4882 for One-Chip Mode
    WriteTNT(_T488_HSSEL, 1);        //Switch TNT to One-Chip mode (ONEC = 1)
    
    //4. Make Sure that the Local Power-On Message is Asserted
    WriteTNT(_7210_AUXMR, 2);        //Local Power-On Message is Asserted
    WriteTNT(_7210_KEYREG, 0);        //clear the swap bit
    //WriteTNT(_7210_EOSR, 0x0a);        //EOS = 0x0a (not used, but initalizing) -- not using EOS
    //WriteTNT(_7210_CDOR, 0);            //clear data lines -- not using CDOR in one-chip mode
    
    //5. Configure the TNT4882 for GPIB Operation
    //A. Set the GPIB Address(es)
    WriteTNT(_7210_ADMR, 0x31);            //set dual primary addressing mode
    WriteTNT(_7210_ADR, g_GPIB_ADDR);    //primary address
    WriteTNT(_7210_ADR, 0xe0);            //no secondary address => E0
    //B. Write the Initial Serial Poll Response
    //WriteTNT(_7210_SPMR, 0x8f);        //Serial poll 10001111 ???
    WriteTNT(_7210_SPMR,0);                //Configure serial poll response
    //C. Configure the Initial Parallel Response
    WriteTNT(_7210_AUXMR,0x70);        //Using remote configuration 01110000
    //D. Setup Interrupts
    WriteTNT(_7210_IMR0,0);        //disable all interrupts
    WriteTNT(_7210_IMR1,0);
    WriteTNT(_7210_IMR2,0);
    WriteTNT(_T488_IMR3,0);
    //E. Set the GPIB Handshake Parameters
    WriteTNT(_7210_HIER, 0xc0);        //DGA DGB - handshake parameters 11000000
    //WriteTNT(_T488_CNT0,0);            //Verify every other bit can be set -- not needed
    //WriteTNT(_T488_CNT1,0);
    //WriteTNT(_T488_CMDR,RESET_FIFO);    //send RESET_FIFO command -- not needed now
    //WriteTNT(_7210_AUXMR,0x88); ???
    WriteTNT(_7210_AUXMR,0xa4);        //enable T1(500ns) delays
    //WriteTNT(_7210_AUXMR,0x8c); ???
    WriteTNT(_7210_AUXMR,0x80);        //unconfigure EOS
    WriteTNT(_7210_AUXMR,0x51);        //Prevent for data reception (HLDI)
    
    //6. Clear the Local Power-On Message to Begin GPIB Operation
    WriteTNT(_7210_AUXMR,0);        //TNT starts operation
    
    ListenGPIB();                        //switch TNT to listener mode
.
.
.
}

The code is working, but I don't know if it's correct.

//WriteTNT(inline implementation) - write one byte of data to TNT, data bus must be setted up by DATAOUT_TNT before use!
#define WriteTNT(cAddr, cData) \
        { \
    Nop();\
    Nop();\
    Nop();\
    Nop();\
            LATF = (LATF & 0xe0) | (cAddr & 0x1f); /*set addr on RA0-RA4*/ \
            LATD = cData; \
    Nop();\
    Nop();\
    Nop();\
    Nop();\
            CSNLO; \
    Nop();\
    Nop();\
    Nop();\
    Nop();\
            WRNLO; \
    Nop();\
    Nop();\
    Nop();\
    Nop();\
    Nop();\
    Nop();\
    Nop();\
    Nop();\
            WRNHI; \
    Nop();\
    Nop();\
    Nop();\
    Nop();\
    Nop();\
    Nop();\
    Nop();\
    Nop();\
            CSNHI; \
    Nop();
    Nop();
    Nop();
    Nop();
}

But after several times turning power on and off (always random number), TNT4882 initialization seems to be failing, and GPIB is not working. It's restoring after next several power on/offs(also randomly). I have two boards with the same problem. Code is written using TNT4882 and some parts of TNT5002 datasheet. There is no problem with sending data over GPIB, it's working fine in 100% cases. But initalization sometimes failing by unknown reason. I just want to know if my code seems to be correct, and there is problem in hardware, or problem in my code. Also if it's my software problem, is there some work-around?

TNT4882's clock is 20 MHz. There may be some problem with clock < 40 MHz or no?
PIC clock is separate clock, also 20 MHz.

Please contact me
angeljanai@gmail.com
or write any ideas in that thread.

Message Edited by NoAngel on 02-21-2007 02:21 PM

--
Best Regards,
NoAngel
0 Kudos
Message 1 of 3
(3,455 Views)

Hello NoAngel,

Your initialization code looks like it follows the manual exactly.  I don't see anything out of the ordinary with it.  How is the initialization function not working?  I would recommend checking the status registers to see if anything is out of place.  Let me know if there are any bits that are not set correctly when you do your check.  A summary of why you think the code does not work would be beneficial.

Steven T.

0 Kudos
Message 2 of 3
(3,425 Views)
Thank You, Steven T.

I think that it was the hardware problem. Now it's cleared by changing TNT4882 clock. Now using 60 MHz clock, and all OK.
 
--
Best Regards,
NoAngel
0 Kudos
Message 3 of 3
(3,411 Views)