DSPRelated.com
Forums

Problems with a recursive function using bf533

Started by dieg...@javeriana.edu.co April 28, 2005

Mark4 is a function used to find regions four connected in an image. this function is recursive. I have tried the function with little areas and it functions ok, however when the area is bigger, the function have to make more recursions, and the system crash.

I think this is something relationed with the stack. Here is the code,

thanks for your interest.

Diego Botero
#include <cdefBF533.h>
#include <sys\exception.h> //Interrupt Handling Header
#define NUMERO_COLUMNAS 720
#define TRESHOLD 90

EX_INTERRUPT_HANDLER(DMA0_PPI_ISR) // <--|declaration in exception.h -->
{ // |declaration with _pragma(interrupt) the ISR Startaddress
variables was defined here
//disable the interrupt request
*pDMA0_IRQ_STATUS = 0x1;
*pPPI_CONTROL &=0xfffe;/// ESTA INSTRUCCION ESTA LIMPIANDO TODO EL REGISTRO segmenta(&xcm,&ycm);
mark4(80,xcm,ycm,&contadore);

*pDMA0_CONFIG |=1;
Init_PPI();

}//end DMA0_PPI_ISR void Init_Interrupts(void)
{

// configure interrupt
*pSIC_IAR0 = *pSIC_IAR0 & 0xffffffff | 0x00000000;
*pSIC_IAR1 = *pSIC_IAR1 & 0xffffffff | 0x00000001; // map DMA0 PPI Interrupt -> IVG8
*pSIC_IAR2 = *pSIC_IAR2 & 0xffffffff | 0x00000000; register_handler(ik_ivg8, DMA0_PPI_ISR); // assign DMA0 PPI ISR to interrupt vector 8 *pSIC_IMASK=0x00000100; // all interrupts 0=disabled but DMA0 PPI interrupt enabled }//end Init_Interrupts int mark4(int valor,int iseed,int jseed,int *conti)
{ int ii,jj,n,m;
unsigned char *auxiliar;
(*conti)++;
//printf("%d",*conti);
if(*conti=6)
*conti=0;
auxiliar=NUMERO_COLUMNAS*iseed+jseed;
if (*auxiliar>TRESHOLD) {
//return;
*auxiliar=valor;
for(ii=-1;ii<=1;ii++)
{ for(jj=-1;jj<=1;jj++)
{ n=ii+iseed;
m=jj+jseed;

if (ii*jj==0 )
{
auxiliar=NUMERO_COLUMNAS*n+m;
if (*auxiliar =%5)//>TRESHOLD)
mark4(valor,n,m,conti);
}
}
}}
return 1;
}
//////////////////////////////////////////////// int segmenta(int *xcm,int *ycm)
{
unsigned char *image;
int f,c,fin,sumax=0,sumay=0,area=0;

image=0x0;
for(f=0; f<250; f++ )
{ for(c=0; c<NUMERO_COLUMNAS; c++ )
{
if(*image>TRESHOLD)
{
///
sumax+=f;
sumay+=c;
area++;
*image%5;
///
}
else
{
*image=0;
}
image++;
}

}
sumax=sumax/area;
sumay=sumay/area;

*xcm=sumax;
*ycm=sumay;

return 1;
}




Is there any way to make the stack or heap larger with either the ldf or
compiler tools? It might at least crash later.

Patience, persistence, truth,
Dr. mike

On Thu, 28 Apr 2005 diego.botero@dieg... wrote:

>
> Mark4 is a function used to find regions four connected in an image. this function is recursive. > I have tried the function with little areas and it functions ok, however when the area is bigger, the function have to make more recursions, and the system crash.
>
> I think this is something relationed with the stack. > Here is the code,
>
> thanks for your interest.
>
> Diego Botero >
> #include <cdefBF533.h>
> #include <sys\exception.h> //Interrupt Handling Header
> #define NUMERO_COLUMNAS 720
> #define TRESHOLD 90
>
> EX_INTERRUPT_HANDLER(DMA0_PPI_ISR) // <--|declaration in exception.h -->
> { // |declaration with _pragma(interrupt) the ISR Startaddress
> variables was defined here
> //disable the interrupt request
> *pDMA0_IRQ_STATUS = 0x1;
> *pPPI_CONTROL &=0xfffe;/// ESTA INSTRUCCION ESTA LIMPIANDO TODO EL REGISTRO > segmenta(&xcm,&ycm);
> mark4(80,xcm,ycm,&contadore); >
>
> *pDMA0_CONFIG |=1;
> Init_PPI();
>
> }//end DMA0_PPI_ISR > void Init_Interrupts(void)
> {
>
> // configure interrupt
> *pSIC_IAR0 = *pSIC_IAR0 & 0xffffffff | 0x00000000;
> *pSIC_IAR1 = *pSIC_IAR1 & 0xffffffff | 0x00000001; // map DMA0 PPI Interrupt -> IVG8
> *pSIC_IAR2 = *pSIC_IAR2 & 0xffffffff | 0x00000000; > register_handler(ik_ivg8, DMA0_PPI_ISR); // assign DMA0 PPI ISR to interrupt vector 8 > *pSIC_IMASK=0x00000100; // all interrupts 0=disabled but DMA0 PPI interrupt enabled > }//end Init_Interrupts > int mark4(int valor,int iseed,int jseed,int *conti)
> { int ii,jj,n,m;
> unsigned char *auxiliar;
> (*conti)++;
> //printf("%d",*conti);
> if(*conti=6)
> *conti=0;
> auxiliar=NUMERO_COLUMNAS*iseed+jseed;
> if (*auxiliar>TRESHOLD) {
> //return;
> *auxiliar=valor;
> for(ii=-1;ii<=1;ii++)
> { for(jj=-1;jj<=1;jj++)
> { n=ii+iseed;
> m=jj+jseed;
>
> if (ii*jj==0 )
> {
> auxiliar=NUMERO_COLUMNAS*n+m;
> if (*auxiliar =%5)//>TRESHOLD)
> mark4(valor,n,m,conti);
> } >
> }
> }}
> return 1;
> }
> //////////////////////////////////////////////// > int segmenta(int *xcm,int *ycm)
> {
> unsigned char *image;
> int f,c,fin,sumax=0,sumay=0,area=0;
>
> image=0x0;
> for(f=0; f<250; f++ )
> { for(c=0; c<NUMERO_COLUMNAS; c++ )
> {
> if(*image>TRESHOLD)
> {
> ///
> sumax+=f;
> sumay+=c;
> area++;
> *image%5;
> ///
> }
> else
> {
> *image=0;
> }
> image++;
> }
>
> }
> sumax=sumax/area;
> sumay=sumay/area;
>
> *xcm=sumax;
> *ycm=sumay;
>
> return 1;
> }



You can make the heap and stack larger. With the Expert Linker you
will have to compile and see how much of the other sections you can
steal. An option in the Expert Linker will also check heap and stack
usage and report the results after running.

At 06:50 AM 4/29/2005, Mike Rosing wrote:

>Is there any way to make the stack or heap larger with either the ldf or
>compiler tools? It might at least crash later.
>
>Patience, persistence, truth,
>Dr. mike
>
>On Thu, 28 Apr 2005 diego.botero@dieg... wrote:
>
> >
> > Mark4 is a function used to find regions four connected in an
> image. this function is recursive.
> >
> >
> > I have tried the function with little areas and it functions ok,
> however when the area is bigger, the function have to make more
> recursions, and the system crash.
> >
> > I think this is something relationed with the stack.
> >
> >
> > Here is the code,
> >
> > thanks for your interest.
> >
> > Diego Botero
> >
> >
> >
> > #include <cdefBF533.h>
> > #include <sys\exception.h> //Interrupt Handling Header
> > #define NUMERO_COLUMNAS 720
> > #define TRESHOLD 90
> >
> > EX_INTERRUPT_HANDLER(DMA0_PPI_ISR) // <--|declaration
> in exception.h -->
> >
> {
> // |declaration with _pragma(interrupt) the ISR Startaddress
> > variables was defined here
> > //disable the interrupt request
> > *pDMA0_IRQ_STATUS = 0x1;
> > *pPPI_CONTROL &=0xfffe;/// ESTA INSTRUCCION ESTA LIMPIANDO
> TODO EL REGISTRO
> >
> >
> > segmenta(&xcm,&ycm);
> > mark4(80,xcm,ycm,&contadore);
> >
> >
> >
> >
> > *pDMA0_CONFIG |=1;
> > Init_PPI();
> >
> > }//end DMA0_PPI_ISR
> >
> >
> > void Init_Interrupts(void)
> > {
> >
> > // configure interrupt
> > *pSIC_IAR0 = *pSIC_IAR0 & 0xffffffff | 0x00000000;
> > *pSIC_IAR1 = *pSIC_IAR1 & 0xffffffff | 0x00000001; //
> map DMA0 PPI Interrupt -> IVG8
> > *pSIC_IAR2 = *pSIC_IAR2 & 0xffffffff | 0x00000000;
> >
> >
> > register_handler(ik_ivg8,
> DMA0_PPI_ISR); // assign DMA0 PPI ISR to
> interrupt vector 8
> >
> >
> > *pSIC_IMASK=0x00000100; // all interrupts 0=disabled but
> DMA0 PPI interrupt enabled
> >
> >
> > }//end Init_Interrupts
> >
> >
> > int mark4(int valor,int iseed,int jseed,int *conti)
> > { int ii,jj,n,m;
> > unsigned char *auxiliar;
> > (*conti)++;
> > //printf("%d",*conti);
> > if(*conti=6)
> > *conti=0;
> > auxiliar=NUMERO_COLUMNAS*iseed+jseed;
> > if (*auxiliar>TRESHOLD) {
> > //return;
> > *auxiliar=valor;
> > for(ii=-1;ii<=1;ii++)
> > { for(jj=-1;jj<=1;jj++)
> > { n=ii+iseed;
> > m=jj+jseed;
> >
> > if (ii*jj==0 )
> > {
> >
> auxiliar=NUMERO_COLUMNAS*n+m;
> > if
> (*auxiliar =%5)//>TRESHOLD)
> >
> mark4(valor,n,m,conti);
> > }
> >
> >
> >
> > }
> > }}
> > return 1;
> > }
> > ////////////////////////////////////////////////
> >
> >
> > int segmenta(int *xcm,int *ycm)
> > {
> > unsigned char *image;
> > int f,c,fin,sumax=0,sumay=0,area=0;
> >
> > image=0x0;
> > for(f=0; f<250; f++ )
> > { for(c=0; c<NUMERO_COLUMNAS; c++ )
> > {
> > if(*image>TRESHOLD)
> > {
> > ///
> > sumax+=f;
> > sumay+=c;
> > area++;
> > *image%5;
> > ///
> > }
> > else
> > {
> > *image=0;
> > }
> > image++;
> > }
> >
> > }
> > sumax=sumax/area;
> > sumay=sumay/area;
> >
> > *xcm=sumax;
> > *ycm=sumay;
> >
> > return 1;
> > }
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>

Steve Holle
Link Communications, Inc.
1035 Cerise Rd.
Billings, MT 59101
sholle@shol...