cancel
Showing results for 
Search instead for 
Did you mean: 

Data abort error

sanjeevk
Associate II
Posted on April 30, 2007 at 14:53

Data abort error

2 REPLIES 2
sanjeevk
Associate II
Posted on May 17, 2011 at 09:42

I am encountering a Data abort error in following piece of code at 00003914(in bold). It's not always that it happens, but randomly. Could somebody please tell me why this happens and how to fix it. In general is there a pattern of code which is likely to generate data abort? I will try to add some more details like the condition various registers at that instant.

BTW I use EWARM of IAR on STR912-SK

u8 Get_latest_USB_out_buf_index(void)

{

Get_latest_USB_out_buf_index:

000038F4 E92D0010 STMDB SP!, {R4}

u8 fl_ret_value=0,loop_count=0;

000038F8 E3A01000 MOV R1, #0x0

fl_ret_value = USB_ALL_OUT_BUFFERS_EMPTY;

000038FC E3A000FF MOV R0, #0xFF

00003900 E59F205C LDR R2, [PC, #+92] ; [0x3964] =USB_buffer_out (0x40004C4)

while(USB_buffer_out[l_read_index].flags == USB_BUFFER_OUT_EMPTY)

00003904 E5D2314D LDRB R3, [R2, #+333]

00003908 E1A0C003 MOV R12, R3

0000390C E3A04042 MOV R4, #0x42

00003910 E02C2C94 MLA R12, R4, R12, R2

00003914 E5DC4000 LDRB R4, [R12, #+0]

00003918 E3540000 CMP R4, #0x0

0000391C 1A00000B BNE 0x003950

l_read_index++;

00003920 E2833001 ADD R3, R3, #0x1

00003924 E5C2314D STRB R3, [R2, #+333]

loop_count++;

00003928 E2811001 ADD R1, R1, #0x1

0000392C E20110FF AND R1, R1, #0xFF

if(l_read_index >= USB_MAX_BUFFER_OUT)

00003930 E20330FF AND R3, R3, #0xFF

00003934 E3530005 CMP R3, #0x5

00003938 3A000001 BCC 0x003944

l_read_index = 0;

0000393C E3A03000 MOV R3, #0x0

Thanks

Sanjeeva

sanjeevk
Associate II
Posted on May 17, 2011 at 09:42

The culprit is 00003910 E02C2C94 MLA R12, R4, R12, R2 . This is

generating a reserved address(between 0x80000000 - 0xFC000000) which is stored in R12 and hence the next instruction 00003914 E5DC4000 LDRB R4, [R12, #+0] promptly generates a data exception. Logically if i follow the sequence of instructions before the MLA and watch the values and do manual calculation of the contents of R12, it seems ok as long as I am stepping thro' the sequence. But if it is made to run on it's own it generates an exception.

BTW I was using the high(speed) optimization level and since moved to low(speed) optimization. This has reduced the frequency of aborts. Means this pattern of coding has less occurences in the generated code. But my guess is that MLA instruction sometimes produces a reserved address if used in indexed addressing(I have an array of structures) mode. Has some body come across this before? if no can somebody tell me is there something amiss in the way compiler generates the opcodes or in the way I am coding?

Thanks

Sanjeeva

[ This message was edited by: Sanjeev on 30-04-2007 18:28 ]

[ This message was edited by: Sanjeev on 30-04-2007 18:29 ]