07-09-2008 11:16 AM
Hi Kevin-
Yes, the address should always be 32-bit but the register widths may vary, as described in the M Series Register Map document. The method you described should work (assuming NI_Write() is correctly implemented to write to offsets from BAR1).
If you must write your own methods for accessing registers (instead of using the MHDDK chipobject libraries), you should also make sure to initialize the MITE properly as shown in main.cpp under initMite(). Until you complete this step, the BAR1 registers will not be accessible.
07-09-2008 08:23 PM
Thanks Tom.
Good explain and clear guide
BR Kevin
07-17-2008 02:34 AM
Hello Tom
I know that NI622X PCI device(s) are consist of 3 port as Port 0,1,2
Normally to use Port0 , user have to set "board->DIO_Direction.writeRegister (0xFF)" then read/write is activaed.
And to use Port1,2 , user have to set "IO_Bidirection_Pin" and "PFI_Output_Select_1~6" then read/write is activated.
Q[1] Can use(access to rea/write) Port0 and Port1,2 simultaneously ?
Q[2] Can it be possible combination Port0+Port1,2+AnalogInput simultaneously ?
Q[3] Refer to Dioex1.cpp, you set as "board->DIO_Direction.writeRegister (0xFF)" before start read/Write.
I'm interesting the value "0xFF", what the meaning of 0xFF ?
At the case of NI6224, it has 32 I/O at Port0 while NI6220 has 8 I/O.
Do I have to set 0xFFFF for NI6224 --> 32 I/O at port0 ?
Q[4] Refer to your RTX sample code (osiUserCode.cpp), it manage two baseaddress.
deviceBar0.QuadPart = pciDeviceData->u.type0.BaseAddresses[0];
deviceBar1.QuadPart = pciDeviceData->u.type0.BaseAddresses[1];
And save it as follow for after usage by "RtMapMemory".
bus->_physBar[0] = deviceBar0.LowPart;
bus->_physBar[1] = deviceBar1.LowPart;
Here I attach my code: If I can succeeded to access second address, everything is clear.
Currently it works well : read eeprom information with successfully
But fail to access second address.
I can't find any issue in my code..
Hope to listen your smart opinion.
BR Kevin
07-17-2008 09:02 AM
07-17-2008 12:01 PM
void Start_DIO(UCHAR order)
{
ULONG addr = message->AnyPci[order].vMapMem1;
Rtx_pci_poked(addr + 0x28/*DIO_Direction*/, 0xFF);}ULONG Port0_Read(UCHAR order)
{
ULONG addr = message->AnyPci[order].vMapMem1;
return Rtx_pci_peekd(addr + 0x24/*Static_Digital_Input*/);
}ULONG Port0_Write(ULONG data, UCHAR order)
{
ULONG addr = message->AnyPci[order].vMapMem1;
return Rtx_pci_poked(addr + 0x24/*Static_Digital_Output*/, data);
}
07-17-2008 12:35 PM
Hello Tom
Forget my previous message,... I solve it. You are right
Back to [Q1] and Q[2] : refer to your remark, I have to manage port0, and port1,2 respect. right?
Analog Input also ..?
many many thanks
BR Kevin
07-17-2008 05:04 PM
Hi Kevin-
I do not understand your question. You must control port0 by itself, port1/2 by itself, and analog input by itself in the MHDDK. There is no way to control any combination of the three by using a single call, and there are no examples to synchronize the three. Is this what you are asking?
07-17-2008 08:35 PM
08-04-2008 02:13 AM
Hello Tom
My project moves final stage to integrate it with test app.
[Q#1] aiConfigureChannel -- aiGetScalingCoefficients
Refer to Aiex1.cpp, user can select gain value by call "aiConfigureChannel".
// intervalIdx
// 0 -> +/- 10V
// 1 -> +/- 5V
// 2 -> +/- 2V
// 3 -> +/- 1V
// 4 -> +/- 500mV
// 5 -> +/- 200mV
// 6 -> +/- 100mV---------------------------------------------------------------------------------------
aiConfigureChannel (board,
i, // channel number
1, // gain -- check ai.h for allowed values
But at the end of Aiex1.cpp "aiGetScalingCoefficients " also needs same kind of value
(at secondparameter), but different value from above.
aiGetScalingCoefficients (eepromMemory, 0, 0, 0, &scale);
In my guess , above two values must be same as parallel,..isn't it?
[#2] differential / single
AI can be controlled by two way as differential & single.
All sample code (aiex1, aiex2.cpp) adapted differental as default by call "aiConfigureChannel " with follow macros.
kAI_Config_PolarityBipolar / kAI_Config_Channel_TypeDifferential
if user want to change it as single instead of differential, which macro(s) are proper combinations & is there any modify area except aiConfigureChannel ?
BR Kevin
08-04-2008 09:35 AM
Hi Kevin-
You are correct- there is an error in the example code where channel range and scaling coefficient intervalIdx are concerned. You should make sure that the value in aiConfigureChannel() from ai.h for intervalIdx match the value for aiGetScalingCoefficients() from scale.h. Note that the two values may not be the same number.
The values for the channelType parameter of aiConfigureChannel() are declared as an enum of type tMSeries::tAI_Config_FIFO_Data::tAI_Config_Channel_Type in tMSeries.h:
typedef
enum {