10-13-2010 09:33 PM
I have an example of aiex1.cpp,I kown it write some bit in some register,I want to translate it into RTX.but I found some register is only wirte and I also dont kown what the default bits in registers is,so use " *(u16*)addr_tmp|= (1 << 7);" is wrong, what can I do about writing some bits in register under RTX? please help me
Solved! Go to Solution.
10-13-2010 09:39 PM
I really dont kown how to write some bits in register under rtx ,bucause some register is " only wire" ,i can not to read it and do some operation for keep other bits unchanging,please some one can tell me what I can do .thanks!
10-14-2010 09:17 AM
The MSeries DDK provides the files that will allow your program to interface with M Series hardware. It shows how to set specific registers and bitfields in the tMSeres.ipp and tMSeries.h files. When the MSeries files are built with an Operating System Interface, you get a working driver that can demonstrate how to interface with the hardware. One of the available operating system interfaces is RTX, so why you are not just building the driver for RTX?
The RTX OS Inteface can be downloaded from the same page as the MSeries DDK.
The DDK Readme talks about how the OS Layer works and how it should be built.
Lastly the tMSeries class demonstrates how to write to the different registers in the hardware.
I hope this helps,
10-15-2010 05:44 AM
hello Steven T,thank you for your answer! I have looked tMSeries.ipp , i found a question .for example ,inline tMSeries::tAI_Command_1& tMSeries::tAI_Command_1::setAI_CONVERT_Pulse(u16 fieldValue, nMDBG::tStatus2* s)
if (s && s->isFatal()) return *this;
u16 newValue; newValue = ((u16)(_softCopy & 0xfffe)) | (((u16)fieldValue << 0x0) & ~0xfffe);
} ,I have found this register calledt AI_Command_1 is "write only",so how _softCopy are read from this register?is it right like doing that?please help me! thank you!
10-15-2010 07:21 AM
now i have another question,when i run the example in rtx,it has an error"cannot open input file "rtxlibcmt.lib",why?i think the rtxlibcmt.lib is written by c, how c++ can call .lib written by c. I am really in trouble,please help me ! thank you very much!
10-15-2010 08:45 AM
Using AI_Command_1 is a good register for a demonstration. When the tMSeries object is constructed, it calls the _initialize() method . This method sets up the initializes the hardware registers and calls the reset()  method to place them all into a known value. The first action that the reset method performs is setting the AI_Command_1 register to 0 . This action results in the soft copy of the register to be set to 0. So, the _softcopy is never read from the register.
At this point, each time that a value is written to the AI_Command_1 register, the soft copy is modified and saved. If this is done correctly, there is no need to read the current value of the register, because your soft copy has the value that was last written to the register.
 Line 18 of tMSeries.cpp, tMSeries constructor calls _initialize()
 Line 351 of tMSeries.cpp, tMSeries _initialize() method calls reset()
 Line 26 of tMSeries.cpp, setting the register to 0.
I need to look into your other issue some more.
10-15-2010 09:26 PM
hello ,thank you very much for your answer!
if that is what you said, in newValue = ((u16)(_softCopy & 0xfffe)) | (((u16)fieldValue << 0x0) & ~0xfffe); ) , does (_softCopy & 0xfffe)) has meaning because of _softCopy=0? why do you use newValue = (((u16)fieldValue << 0x0) & ~0xfffe) instead of
newValue = ((u16)(_softCopy & 0xfffe)) | (((u16)fieldValue << 0x0) & ~0xfffe); ) ? i think (_softCopy & 0xfffe)=0 according to what your said.Maybe what i think is wrong. i really don't understand,please help me.
10-16-2010 08:44 AM
I build the project when i set active configuration project as win32 debug ,it success! but when i set active configuration project as win32 RTss Release ,it has two error:
rtapi_rtss.lib(startup.obj) : error LNK2005: __fltused already defined in rtxlibcmt.lib(fpinit.obj)
Pxi___Win32_RTSS_Release/Pxi.rtss : fatal error LNK1169: one or more multiply defined symbols found
why?? do i need to rewrite code for win32 RTss Release?
do i set the environment is wrong?
10-19-2010 08:25 AM
Yes, the _softCopy starts out at 0. However, please remember that the _softCopy isn't always 0. After the line you mention runs, a value is saved in newValue...after flushing newValue to the register, that value is also saved in _softCopy. Basically, this proceedure ensures that the other bit fields in _softCopy are not modified unintentionally.
If you have any doubts about what is happening, I would recommend stepping through the code while it is running so that you can see what is happening in that line (you may wan to break it out into multiple lines).
Regarding the errors you are getting in RTX, please follow the readme for building the examples with this OS interface. The Readme says that it was tested with RTX 6.1. If you are using a later version, you may need to contend with any changes that may have happened with this operating system. If you work through any issues, please post back to let us know what went wrong. We welcome any feedback about this OS interface!
10-22-2010 10:09 AM