Jump to content
OMRON Forums

Digital IO access from Capps via shared memory


KEJR

Recommended Posts

Hello, In some of the examples I have been reading there are references to setting and reading IO bits on the accessory IO cards, but the reads and writes are to entire bytes (IO 0-7, 8-15, etc). Since the C compiler needs to do a Read-Modify-Write to the shared memory there is risk of another thread corrupting the data midway in the write cycle. Does DT have any way of solving this, or should we write our own function calls that include the mutex lock/unlock calls to make it thread safe?
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

The PPmac memory is atomic. So 32-bit or 64-bit access happens in one cycle. If you access the shared memory with a pointer pSHM-> then you must consider if read modify write is an issue for the task you are doing. If you use the functions we have built in the API then we have taken care of the problem. The biggest issue is that the C functions are not well documented yet so there is no manual to go to and see what can be done. There are two main ways to do this. First is with the structure name and the API functions GetPtrVar() and SetPtrVar(). Usually you will have an PTR variable pointing to any user buffer memory or IO you need to manipulate. Then there is the GetResponse() in which you can read or Set any structure element. IO cards except for ACC11E will have pre-assigned structures for each IO bank. These are the best ways of doing what you need. Then if there is some general things to do you can also use lower level functions described In the header file ftp://{your IP}/ppmaclibs/libppmac/rtpmaclib.h you will fine these prototypes. void bfwrite(volatile int *, int, int, int); // write a bit pattern int test_bits_set(int, volatile int *); // test if bits are set int test_bits_clr(int, volatile int *); // test if bits are cleared
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...