Hi.
I use the micro lm3s6965 , it works fine.
I added a quicksort routine , It works fine on another board ( with lm3s6965 ).
Once I added a quicksort routine , The program hangs.
With the debugger I see that it stops on
FaultISR B FaultISR
Is there a way to know the source of this problem ?.
Please Advise.
Attached the source of the quicksort.
void swap(unsigned short *x,unsigned short *y){ unsigned short temp; temp = *x; *x = *y; *y = temp;}
int choose_pivot(int i,int j ){ return((i+j) /2);}
void quicksort(unsigned short list[],int m,int n){ int i,j,k; unsigned short key; if( m < n) { k = choose_pivot(m,n); swap(&list[m],&list[k]); key = list[m]; i = m + 1; j = n; while(i <= j) { while((i <= n) && (list[i] <= key)) i++; while((j >= m) && (list[j] > key)) j--; if( i < j) swap(&list[i],&list[j]); } // swap two elements swap(&list[m],&list[j]); // recursively sort the lesser list quicksort(list,m,j - 1); quicksort(list,j + 1,n); }}
ephraim oved Is there a way to know the source of this problem ?.
Yes.
There are 2 approaches:
ephraim oved recursively sort the lesser list
Think about what is the key risk of doing anything recursively...?
Can you be more specific.
Bye.
About what?
more specific about
The input to the quicsort is 20 unsigned short numbers.
Think about it!
As I said, there is a key risk of doing anything recursively - isn't there?
It is inherent in the nature of recursion - nothing specifically to do with Stellaris or embedded systems, although the fact that these are memory constrained means that you are likely to hit the problem sooner that on PCs or other "big" systems...
Think about what happens each time you call a function from within a function from within a function from... - can that just go on ad infinitum?