Posted 31 Aug 2006 Hi Can somebody help me, I have to swap some bytes. I have made commonication with a weighing transmitter via profibus. The weight signal is a 32 bit Dint signal. But i have to swap the bytes (4) as followring: SWAP DINT Byte O MSB Byte 3 Byte 1 ---------------> Byte 2 Byte 2 Byte 1 Byte 3 LSB Byte 0 I'am using a CJ CPU. Regards, Banker Share this post Link to post Share on other sites
Posted 1 Sep 2006 Use the SWAP function. You can specify the starting word and how many words and the function will swap the bytes for you. The last time I used it I specified quite a large block of words and it worked fine. Now if there was a similar swap word function zzzzzzzzzzz. Yes I can use transfer but it is messy and swap word would be much much easier!!!!! Share this post Link to post Share on other sites
Posted 1 Sep 2006 ?ou have right is much easier using swap function but CPM1A-CPM2A do not supprort this function! Share this post Link to post Share on other sites
Posted 1 Sep 2006 Correct, only CJ1 and CS1 - latest processors - maybe CP1 - have not used one yet. Share this post Link to post Share on other sites
Posted 3 Sep 2006 that's ok since the OP is using a CJ Share this post Link to post Share on other sites
Posted 7 Sep 2006 Bobb.... seen the XCHG and the XCGL functions Bob fro the CJ's .. ? Share this post Link to post Share on other sites
Posted 8 Sep 2006 Been there done that Sleepy. Not smart enough - SWAP allows start word and how many words in the one instruction. XCHG only allows 2 words and XCGL only allows 2 long words. Pain in the "A" if you have to swap 40-50 words. Come on Omron - a smarter XCHG would be most welcome!!!! Share this post Link to post Share on other sites
Posted 8 Sep 2006 (edited) ... Bob, You could use a for - next loop with XCHG, IR registers (ir+ etc), would do 40 - 50 words easy, with a few rungs of code ... ?? The Code below swaps 40 words ... (Do admit that XCHG would probably be handier if it operated more like SWAP) Nibroc Edited 8 Sep 2006 by Nibroc Share this post Link to post Share on other sites