Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

visa and PCI-DIO-96

Hello,
I use for a long time  PCI-DIO96 boards in some Mac ender OS 9.2
I used to perform I/O with register-based access as described  "PCI-DIO-96 user manual" sections 6-4 et 6-5 (old edition : Jan 97!!).

I am migrating every thing to OS X (10.4), and I liked to continue with the same strategy.
I have read with a lot of interest the (most recent!) NI-VISA documentation, that apparently gives simple access to the Rsrc and adresses.The doc is very well written.
I am anyway very disapointed by the results i've gotSmiley Sad :
-viOut8(instr1, VI_PXI_BAR1_SPACE, chipB|portC, writebyte); //has no effect on the lines (allthought chipB/portC is configured as output)
-viIn8(instr1, VI_PXI_BAR1_SPACE, chipB|portC, &readbyte); //crashes immediately.(the complete Mac OS X !!)
So I think:
  1. either the adresses i've got are wrong,(is it really BAR0 et BAR1 as on PCs ?, see sect 6-3),
  2. either the prgrammation of the ASIC MITE is wrong (but is was working well with OS9)
  3. either I missed some step.
Thanks for your help.

Here is my 'sample code'.
(FindDIORsrc(), non reported here merely opens a ViSession to the "PXI*?INSTR"  and this with no error neither as recorded by Ni Spy).

ViStatus status;
ViSession instr0= FindDIORsrc();//make a first VI session to PXI0:20:INSTR . This session will access BAR0=the MITE ASIC of the board.
void*address0;status = viMapAddress(instr0, VI_PXI_BAR0_SPACE, 0, 0x1000, VI_FALSE, VI_NULL, &address0);
if (status < VI_SUCCESS)cout<<"Could not map to VI_PXI_BAR0_SPACE "<<flush;else cout<<"Could map to VI_PXI_BAR0_SPACE "<<hex<<address0<<flush;


//step 4 : get the card base adress (cardregister)
ViSession instr1= FindDIORsrc();//make a second VI session to PXI0:20:INSTR . This session will access BAR1=the card's registers
void*address1;status = viMapAddress(instr1, VI_PXI_BAR1_SPACE, 0, 0x1000, VI_FALSE, VI_NULL, &address1);
if (status < VI_SUCCESS)cout<<"Could not map to VI_PXI_BAR1_SPACE "<<flush;else cout<<"Could map to VI_PXI_BAR1_SPACE "<<hex<<address1<<flush;

//step 5 : write the specified value for programming the ASIC.
status = viOut32(instr0, VI_PXI_BAR0_SPACE, 0xc0, EndianSwap32Bit((0xffffff00&((long int)address1))|0x00000080L));
//please note that the result is the same without EndianSwap32Bit
if (status < VI_SUCCESS)cout<<"Could not write to the MITE adress + 0xc0"<<flush;
cout<<"new card adress is "<<hex<<address1<<flush;//this adress might be used for direct I/O to registers.

//set PPI B for Output on A,B,C ports.(chipB,portcnt,AOUT,BOUT,COUT are defined in accordance with the documentation).
status = viOut8(instr1, VI_PXI_BAR1_SPACE, chipB|portcnt, AOUT|BOUT|COUT);
if (status < VI_SUCCESS)cout<<"Could not write to portcnt"<<flush; else cout<<"Could write to portcnt"<<flush;

byte readbyte, writebyte;
writebyte=0;
status=viOut8(instr1, VI_PXI_BAR1_SPACE, chipB|portC, writebyte);if (status < VI_SUCCESS)cout<<"Could not write to portC"<<flush;else cout<<"Could write to chipB|portC"<<flush;

/* This is the output if we stop here :

1 PXI?*INSTR instruments resources.
A session was succesfully open with PXI0::20::INSTR
Could map to VI_PXI_BAR0_SPACE 0x837e000
1 PXI?*INSTR instruments resources.
A session was succesfully open with PXI0::20::INSTR
Could map to VI_PXI_BAR1_SPACE 0x837f000
new card adress is 0x837f000
Could write to portcnt
Could write to portcnt
Could write to chipB|portC

Note that no error is reported by Ni Spy down to this point.
*/

//If the following code is executed, the Mac is crashed instantaneously :
status=viIn8(instr1, VI_PXI_BAR1_SPACE, chipB|portC,&readbyte);if (status < VI_SUCCESS)cout<<"Could not read portC"<<flush;
if (readbyte!=writebyte)cout<<"chipB|portC didnot work"<<flush; else cout<<"chipB|portC did work"<<flush;
0 Kudos
Message 1 of 1
(3,515 Views)