7/21/2014 3:28 PM | |
Joined: 1/17/2007 Last visit: 10/21/2024 Posts: 1547 Rating: (537) |
Your structures are incorrect. You have:- ID :BYTE; S_data_type:BYTE; S_length:BYTE; S_DB_nr : INT; S_speicherbereich:DWORD; S_Byte_ptr_msb:BYTE; S_Byte_ptr_lsb:WORD; The structure should be:- ID (1 byte) Data type (1 byte) Length (2 bytes) DB Number (2 bytes) Area ponter (4 bytes) Making a total of 10 bytes. You have used both speicherbereich and Byte_ptr_msb / Byte_ptr_lsb. You have also set speicherbereich incorrectly. You have set it to dw#16#84 which equates to dw#16#00000084. This is nonsense as your ANY pointer is 14 bytes in length and not 10 as it should be. You should use one or the other. If you just want the data into the start of the DB you can just use speicherbereich and set it to DW#16#84000000 and delete the S_Byte_ptr_msb and S_Byte_ptr_lsb elements. If you want to use other addresses in the DB other than 0, then you will need a different structure. Delete the speicherbereich and add these in place of it:- MemoryArea:Byte S_Byte_ptr_msb:BYTE; S_Byte_ptr_lsb:WORD; Then set MemoryArea to B#16#84 and then set S_Byte_ptr_lsb to the byte address (0 = byte 0, 8 = byte 1, 16 = byte 2 etc.). Leave S_Byte_ptr_msb at 0 for now as this only comes into play when you want to access DB addresses greater then 8192 bytes. Basically the area pointer is in the format:- 10000ZZZ 00000YYY YYYYYYYY YYYYYXXX Where ZZZ is the perand area (in your case 4 (2#100) = Global data block). YYY YYYYYYYY YYYYY is the byte address XXX is the bit address (this MUST always be 0 when using BLKMOV as BLKMOV can only move full bytes and byte alligned boundaries). So in your case 2#10000ZZZ = 2#100000100 = 16#84. The 00000YYY YYYYYYYY YYYYYXXX would be your byte address bit shifted left by 3 bit positions. For example if you wanted to access byte 10 it would be dw#2#0000 0000 0000 0000 0000 0000 0000 1010 bit shifted ledt by 3 = dw#2#0000 0000 0000 0000 0000 0000 0101 0000 = 80 (or 16#50). Note that this 10 * 8 as there are 8 bits in a byte. See the following thread for more details on ANY pointers. /tf/WW/en/Posts/50677n |
Last edited by: smiffy at: 7/21/2014 3:30 PMProgramming today is the race between software engineers building bigger and better idiot proof programs, and the universe producing bigger and better idiots. |
|
This contribution was helpful to1 thankful Users |
7/21/2014 3:54 PM | |
Posts: 11 Rating: (0) |
Yes, I am getting the same error. My DBs are defined and contain string variables at 0.0 I am using CPU 416-2.Could that be the cause of the problem? |
Follow us on