Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

Register Level Programming under CeWin RealTime OS

Hello everybody,
 
I'm using the RealTime OS CeWin from KukaControls to access an E-Series NI DAQ Card.
I've read the Register Programming Manual and the STC Technical Reference Manual, but it doesn't seem to work. Here's my simple C++ example:
 
#define STC        BaseAddressSTC
#define MITE       BaseAddressMITE
 
class CNICard
{
public:
 char PCIInit();
 void WriteByte(DWORD Addr, WORD Offset, BYTE Data);
 BYTE ReadByte(DWORD Addr, WORD Offset);
 WORD ReadWord(DWORD Addr, WORD Offset);
 void WriteWord(DWORD Addr, WORD Offset, WORD Data);
 DWORD ReadDWord(DWORD Addr, WORD Offset);
 void WriteDWord(DWORD Addr, WORD Offset, DWORD Data);
 void DOTest();
private:
 DWORD BaseAddressSTC;
 DWORD BaseAddressMITE;
};
 
char CNICard::PCIInit()
{
 BOOL   Result;
 DWORD  VirtAddress;
 CEWINPCIINFO PciInfo;
 DWORD   BaseAddressBAR0;
 DWORD   BaseAddressBAR1;
 DWORD   Reg;
 DWORD   Value;
 Result = CeWinPciGetInfo(NIDAQ_NAME, &PciInfo);
    if(!Result)
 {
  return 1;
 }
 //Mapping of BAR0
 VirtAddress = CeWinPciMapMemory(&PciInfo, NIDAQ_MEM_INDEX_BAR0);
 if (VirtAddress == 0)
 {
  return 1;
 }
 BaseAddressBAR0 = (volatile) VirtAddress;
 //Mapping of BAR1
 VirtAddress = CeWinPciMapMemory(&PciInfo, NIDAQ_MEM_INDEX_BAR1); 
 if (VirtAddress == 0)
 {
  return 1;
 }
 BaseAddressBAR1 = (volatile) VirtAddress;
 BaseAddressMITE = BaseAddressBAR0; 
 BaseAddressSTC = BaseAddressBAR1;  
 
 WriteDWord(MITE,0xc0,(PciInfo.Window.memWindows[0x1].dwBase & 0xffffff00) | 0x80);
 
 Value = ReadDWord(MITE,0x300); //For Testing only, here it returns the correct device and vendor id

 //PCI-Karte gefunden
 return 0;
}
 
void CNICard::DOTest()
{
 
WriteByte(STC,0x0b,0xff); //Config as outputs
 
 for (int port_val = 0; port_val< = 255; port_val++)
 {
   WriteByte(STC,0x0a, port_val);
 }
}
 
As is already wrote in the comment, the MITE returns the correct values for device and vendor id, so it's adresses correctly.
The adresses are Bar0(MITE) 0xE8201000 and Bar1(STC) 0xE8200000, which is masked and written back to the MITE.
But on the digital output lines of the card i can't see anything. Can anybody help? Is there any test I can perform to check that the STC is adressed correctly?
 
Thanks and greetings from Germany,
Thomas
 
 

Message Edited by ThomasF on 03-08-2006 05:46 AM

Message Edited by ThomasF on 03-08-2006 05:48 AM

0 Kudos
Message 1 of 4
(7,888 Views)
Here are the Read/Write functions:
 
void CNICard::WriteByte(DWORD Addr, WORD Offset, BYTE Data)
{
 DWORD* pAValue;
 DWORD Reg;
 
 Reg = Addr + Offset;
 pAValue = (PDWORD)Reg;
 *pAValue = Data;
}
 
void CNICard::WriteDWord(DWORD Addr, WORD Offset, DWORD Data)
{
 DWORD* pAValue;
 DWORD Reg;
 
 Reg = Addr + Offset;
 pAValue = (PDWORD)Reg;
 *pAValue = Data;
}
 
DWORD CNICard::ReadDWord(DWORD Addr, WORD Offset)
{
 DWORD*  pAValue;
 DWORD   Reg;
 DWORD   WordValue;
 Reg = Addr + Offset;
 pAValue = (PDWORD)Reg;
 WordValue = (DWORD)(*pAValue);
 return(WordValue);
}
0 Kudos
Message 2 of 4
(7,881 Views)

Have you taken a look at the example programs in the Measurement Hardware Driver Development Kit?  These might be a god starting point and will provide a working set of examples.  One option is to port the bus interface to your OS, instead of writing a driver AND developing your own sequence of register accesses.

 
0 Kudos
Message 3 of 4
(7,871 Views)
Ok, that worked well for me... porting the bus interface was a good idea..
Thank you
0 Kudos
Message 4 of 4
(7,852 Views)