I just looked at the NAT7210 data sheet and the DO bit is set by (TACS & SGNS & ~nba), which means that the NAT7210 will tell you that the controller is requesting a data byte when you are addressed a talker and ATN is unasserted. This says nothing about whether the NRFD line is unasserted and the host is really requesting data. This is as I described it earlier, I just wanted to make sure.
The problem with this definition is that you will do the following:
Device1 buffer: ABC\n
Device2 buffer: DEF\n
Assume that everytime you are requested to talk, you just repeat the same message:
Host Address Device 1 and read (Generates ADSC interrupt and then a DO interrupt requesting the first byte)
Device 1 places 'A' in CDOR (Generates DO interrupt when sent across the bus)
Device 1 places 'B' in CDOR (Generates DO interrupt when sent across the bus)
Device 1 places 'C' in CDOR (Generates DO interrupt when sent across the bus)
Device 1 places '\n' in CDOR w/EOI (Generates DO interrupt when sent across the bus)
Device 1 places 'A' in CDOR [*I think this is the problem, but Device 1 is addressed as a talker and you get a DO interrupt, so...]
Host Address Device 2 and read (Generates ADSC interrupt and then gets the 'A' and then generates DO interrupt
Device 2 places 'D' in CDOR (Generates DO interrupt when sent across the bus)
Device 2 places 'E' in CDOR (Generates DO interrupt when sent across the bus)
Device 2 places 'F' in CDOR (Generates DO interrupt when sent across the bus)
Device 2 places '\n' in CDOR w/EOI (Generates DO interrupt when sent across the bus)
This is what would happen if you just handle the DO interrupt to send data. However, I have a new, simpler way of handling this that doesn't require polling for NRFD. When you get DO interrupt, you know you are in TACS, so you will also enable an interrupt for ATN. When the controller asserts ATN to send a command byte (required before it can change your addressing from Device 1 to Device 2) you will get the ATN interrupt. If you get an ATN interrupt, than you have not sent that byte across the bus and likely a "wrong" byte is stuck in the CDOR. Therefore, set the auxillary command nbaf, which tells the NAT7210 that the byte that you put in the CDOR is not a valid byte (clears nba). [Make sure you back up your array index so that you don't skip the byte next time Device 1 is a talker.] Then, the next that ATN is unasserted, you will get a new DO interrupt. In the ISR, you do as you normally do (I expect) and check the MJMN bit to determine which device should talk and load the CDOR with that byte.
Regarding the 6 or 7 interrupts for 5 bytes, this depends on which interrupts you have enabled. The 7210 generates an ADSC interrupt [isr2.0] when your addressing state changes from TIDS to TADS and then again from TADS to TACS. Then you will get a DO interrupt indicating that the controller requests a byte. Then, you will get another DO interrupt for each byte that is requested and one more when the last byte is sent, so you can get anywhere from 6 to 8 interrupts depending on your current state and the enabled interrupts.
Message Edited by GPIB Guru on 03-09-2006 07:28 AM