LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

viMapAddress() error while mapping PCI bus hardware with VISA driver library

Hi all,
 
I'm trying to use the VISA driver in CVI to communicate with a PCI bus card (my device under test).  I used the VISA wizard to detect my PCI card and install a driver in the Windows registry...that worked great.   Then I followed the example CVI code in the VISA driver wizard application note on the NI website.   My code compiles fine, but I get a fatal run-time error when I try to call the viMapAddress() library function;  the error messge is :
 
"FATAL RUN-TIME ERROR:   "PDAQ_PCI_access_stripped_down.c", line 68, col 38, thread id 0x00000C40:   Uninitialized pointer argument to library function"
 
and the debugger highlights the last parameter in my function call (pdaq_fpga_base_addr).  See below for source code.
I thought the whole point of the viMapAddress() function was to take an empty pointer and FILL IT with a valid address.  So why is it complaining that the pointer is un-initialized when the function is called ?
 
I've checked the function panel and on-line help for viMapAddress() and I think I'm doing everything right.  I've also called the Tech Support hotline, but the guy was a junior engineer who was able to reproduce the error, but not able to tell me what was causing it.  He said it would take a couple days to figure it out and get back to me.
 
Any body have ideas on what's going on?  How do I fix this error?  I've got LabWindows/CVI version 8.0 if that makes any difference.
 
Thanks !!
 
Erik
 
void PDAQ_init_with_NI_VISA( void )
{
  ViStatus status;
  ViPAddr pdaq_fpga_base_addr;
  
  // open National Instruments VISA default resource manager
  status = viOpenDefaultRM( &defaultRM );
  // open NI-VISA handle to PDAQ3 VISA driver  - this is my PCI card
  status = viOpen( defaultRM, "PXI5::4::INSTR", VI_NULL, VI_NULL, &PDAQ3_PLX );
 
  // map physical memory
  status = viMapAddress( PDAQ3_PLX, VI_PXI_BAR2_SPACE, 0, pdaq_pci_bar2_size,
                                             0, VI_NULL, pdaq_fpga_base_addr );
                                                                                    ^
                                                                                    ^
                                                                last parameter highlighted in blue with debugger error message
}
0 Kudos
Message 1 of 5
(5,023 Views)
I'm pretty sure for the last paramter of viMapAddress you want to pass &pdaq_fpga_base_addr instead of pdaq_fpga_base_addr. The function expects the address of the variable to fill; you are passing in the variable itself, which is indeed uninitialized
0 Kudos
Message 2 of 5
(5,021 Views)

Sorry Alex...but that's not the correct answer.   I tried it that way first because it seemed logical and because the example code showed it that way.  But the compiler complained...the latest version of the function in the VISA library actually requires a new variable type ViPAddr which is itself a pointer to a far.   Now the compiler is happy, but the run-time code is not.

But thanks for responding so quickly,

Erik

 

0 Kudos
Message 3 of 5
(5,017 Views)

ViPAddr is actually just a typedef for a pointer to a ViAddr (sorry, I missed the P in my initial reading). pdaq_fpga_base_addr should be declarared as a ViAddr (not a ViPAddr) and you should take the address of it when passing it to viMapAddress. This seems to work fine for me in CVI 8.0; if you still have problems, could you please post the text of the error you receive? Here is the revised code:

void PDAQ_init_with_NI_VISA( void )
{
  ViSession defaultRM, PDAQ3_PLX;
  ViStatus status;
  ViAddr daq_fpga_base_addr;
 
  // open National Instruments VISA default resource manager
  status = viOpenDefaultRM( &defaultRM );

  // open NI-VISA handle to PDAQ3 VISA driver  - this is my PCI card
  status = viOpen( defaultRM, "PXI5::4::INSTR", VI_NULL, VI_NULL, &PDAQ3_PLX );
 
  // map physical memory
  status = viMapAddress (PDAQ3_PLX, 0, VI_PXI_BAR2_SPACE, pdaq_pci_bar2_size, 0, VI_NULL, &daq_fpga_base_addr);
}

Thanks,

-alex

Message 4 of 5
(5,013 Views)
 
You are the MAN Alex...that worked great !!
 
I wish they would have listed that parameter as ViAddr * in the function panel and online help...that would have been so much clearer than creating a new typedef ViPAddr
 
Thanks for your help,
 
Erik
 
0 Kudos
Message 5 of 5
(5,009 Views)