XGATE Warning A22011 Operand out of range

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

XGATE Warning A22011 Operand out of range

跳至解决方案
284 次查看
roberthiebert
Senior Contributor I

MC9S12XEP100, CW Special edition, relocatable assembler, dual processor, XGATE in RAM.

I'm having some success in my project getting XGATE to handle some of the interrupts, but I've run into an interesting problem. Things worked well until I started adding more shared variables. At one point I got the warning "A22011 Operand out of range".

My project is getting fairly big and complex so I just made a short test program to re-create the problem. The program is just the Fibo one that the wizard puts together with some more shared variables added. Up to 16 word variables is fine, after that it I get the warning and when I run the program the variables beyond 16 don't update.

I have no idea how to fix this. Any suggestions would be greatly appreciated.

Regards,

Robert

0 项奖励
回复
1 解答
130 次查看
lama
NXP TechSupport
NXP TechSupport

Hi,

I have forgotten….. The instruction you use in given form has offset of 5 bits long, represents number of bytes and you use words.
M[RB, #OFFS5] ⇒RD
So max offset is 32 bytes or 16 words.

Look at this simple example of writing the Array of 256 words addressed by variable index.
Note that R0 is always 0.
XGATE_DATA: SECTION

; put your variables here
ALIGN 2
Arr DS.W 256
Index DS.W 1

XGATE_CODE: SECTION

; interrupt handler for the software trigger 0
ALIGN 2
SoftwareTrigger0_Handler:

; load index with value
LDW R2, Index ; Addr to Index
LDL R3, #17 ;
STW R3, (R2,R0) ; Save Index value
;-------------------------- Write Arr[5] = 0x1234
LDW R3, Index ; Get address of Index
; R3 = get address of index
LDW R2, (R3, R0) ; R2 = Index
LSL R2, #$1 ; Calculate Index in bytes; R2 = Index*2 data set is size of word
; Get position of Arr[Index]
LDW R3, Arr ; Base address of Addr
ADD R4, R2,R3 ; Calculate Arr[Index] position = Arr + Index*2
LDW R3, #$1234
STW R3, (R4, R0) ; Write Arr[Index] = $1234

Note, in the memory window you will see Arr[0..512] (even we defined Arr DS.W 256) so writing word to arr index 17 will in reality write word to Arr[34] and arr[35] in memory window.

Note that similar is read from the array.

 

If you want to use instruction with #OFF5 then you can make something like addressing 2dimensional array of words which has elements [x,16]. But I see this as little bit complicated.

 

Best regards,

L.

在原帖中查看解决方案

0 项奖励
回复
7 回复数
239 次查看
roberthiebert
Senior Contributor I

I've been doing some more troubleshooting on this, reading the manuals, studying the PRM and .map files and using the debugger. I am using non-paged RAM and non-banked Flash.

The manual tells me that XGATE register R1 is preloaded with the initial pointer of the channel's service request vector. XGATE register R7 is preloaded with either the contents of XG1SP74 or XG1SP31.

Using the de-bugger I can see that the the linker has placed the shared variables  starting at address XGATE $E100. Addresses XGATE $E100 to $FFFF correspond to logical addresses $2100 to $3FFF.

With R1 containing $E100 I can only access 16 variables before I get and "out of range " error.

 

In my project I eventually want XGATE to handle 27 different interrupt routines. One of which has to use a 256 byte lookup table.

Any suggestions on how I can handle this issue would be greatly appreciated.

Regards,

Robert

0 项奖励
回复
228 次查看
roberthiebert
Senior Contributor I

Oops. Error on last post. Should be 32 variables (16 words), not 16 variables.

0 项奖励
回复
187 次查看
lama
NXP TechSupport
NXP TechSupport

Hi,

The question I have is > What do you want to do....


LDW R2,(R1,#(XGATE_CounterXX - MyData)) ; load counter
INC R2
STW R2,(R1,#(XGATE_CounterXX - MyData)) ; store counter

Is that right you want to get a value from XGATE_CounterXX, increment it and then put it back?
Or do you want to get an offset of the XGATE_CounterXX from MyData, incremnt it and put the value to the XGATE_CounterXX?
Or....?

Best regards,
Ladislav

0 项奖励
回复
180 次查看
roberthiebert
Senior Contributor I

Hi Ladislav,

Thanks very much for having a look at my code.

In this test code I just want to load the contents of XGATE_CounterXX, increment it and store it back into XGATE_CounterXX. The code works fine until I get to XGATE_Counter_17, then I get the out of range error.

It would be preferable if I could get the value from XGATE_Counter_17 (and on for more variables) by using the offset from the beginning of .data. I assumed that the command line

LDW R2,(R1,#(XGATE_CounterXX - MyData)) did just that, but it seems to limit me to a maximum of 32 bytes or 16 words from the start of .data.

Just what is it that the command LDW R2,(R1,#(XGATE_CounterXX - MyData)) does? I can't find any description of it in any of the information that I have.

If my interpretation of the manuals is correct, it is faster (more efficient?) to run XGATE out of RAM rather than Flash, and isn't that the  whole point of using XGATE to handle the interrupts? 

Using "C" language for anything for me is not an option because I do not speak the language.  

0 项奖励
回复
131 次查看
lama
NXP TechSupport
NXP TechSupport

Hi,

I have forgotten….. The instruction you use in given form has offset of 5 bits long, represents number of bytes and you use words.
M[RB, #OFFS5] ⇒RD
So max offset is 32 bytes or 16 words.

Look at this simple example of writing the Array of 256 words addressed by variable index.
Note that R0 is always 0.
XGATE_DATA: SECTION

; put your variables here
ALIGN 2
Arr DS.W 256
Index DS.W 1

XGATE_CODE: SECTION

; interrupt handler for the software trigger 0
ALIGN 2
SoftwareTrigger0_Handler:

; load index with value
LDW R2, Index ; Addr to Index
LDL R3, #17 ;
STW R3, (R2,R0) ; Save Index value
;-------------------------- Write Arr[5] = 0x1234
LDW R3, Index ; Get address of Index
; R3 = get address of index
LDW R2, (R3, R0) ; R2 = Index
LSL R2, #$1 ; Calculate Index in bytes; R2 = Index*2 data set is size of word
; Get position of Arr[Index]
LDW R3, Arr ; Base address of Addr
ADD R4, R2,R3 ; Calculate Arr[Index] position = Arr + Index*2
LDW R3, #$1234
STW R3, (R4, R0) ; Write Arr[Index] = $1234

Note, in the memory window you will see Arr[0..512] (even we defined Arr DS.W 256) so writing word to arr index 17 will in reality write word to Arr[34] and arr[35] in memory window.

Note that similar is read from the array.

 

If you want to use instruction with #OFF5 then you can make something like addressing 2dimensional array of words which has elements [x,16]. But I see this as little bit complicated.

 

Best regards,

L.

0 项奖励
回复
99 次查看
roberthiebert
Senior Contributor I

Hi Ladisalv,

Excellent! That was what I needed. I studied your code and it made sense to me . I incorporated it into a basic test code and it worked as expected. I experimented with it a bit and that also worked as expected.

Thanks so much for giving me that clue to the puzzle.

Now, I have one more related related question about XGATE semaphores, but I think it would be better protocol to start and new thread, which I will do. 

Thanks again for your help, I don't know if I could have figured it out on my own or not.

Regards,

Robert. 

0 项奖励
回复
184 次查看
lama
NXP TechSupport
NXP TechSupport

Hi,

having read last update I started to be more confused.
Would not be easier to prepare c code example as a development platform.

Moreover, think about xgate in flash and ram, or process basic functions on xgate and then call (continue) with the interrupt on CPU (it is also possible). 

BR

Ladislav

0 项奖励
回复