cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
phdwong
Explorer
Explorer
2,907 Views
Registered: ‎09-15-2011

About For loop

Jump to solution

dear all

 

i have some questions about the part of code

 

#define K 5
#define Q 6
#define SYS_XCOEF_MID1 0x833C8210
#define SYS_XCOEF_BEGIN 0x833C8214
#define LENGTH 256 #define XIo_OutFloat(OutputPtr, Value) \ (*(volatile float *)((OutputPtr)) = (Value)) #define XIo_InFloat(InputPtr) (*(volatile float *)(InputPtr)) /**The complex data struct**/ typedef struct { float re; float im; } fcomplex; /**************************Function Prototypes*******************************/ /** **z=z1+z2; **/ fcomplex ffadd(fcomplex z1, fcomplex z2) { fcomplex z; z.re=z1.re+z2.re; z.im=z1.im+z2.im; return (z); } /** **z=z1*z2; **/ fcomplex ffmul(fcomplex z1, fcomplex z2) { fcomplex z; z.re=(z1.re*z2.re)-(z1.im*z2.im); z.im=(z1.re*z2.im)+(z1.im*z2.re); return (z); } /** **z=abs(z1)^i; **/ float fpower(fcomplex z1, int i) { float z; z = ffsqrt(z1); if(z<=0) return 0; else { switch(i) { case 0: return 1.0; break; case 1: return (float)(pow(z,1.0)); break; case 2: return (float)(pow(z,2.0)); break; case 3: return (float)(pow(z,3)); break; case 4: return (float)(pow(z,4)); break; case 5: return (float)(pow(z,5)); break; case 6: return (float)(pow(z,6)); break; case 7: return (float)(pow(z,7)); break; case 8: return (float)(pow(z,8)); break; case 9: return (float)(pow(z,9)); break; default: return 0; } } } void Test(void) { int m; int n; int i; int j; fcomplex sum; fcomplex temp1; fcomplex temp2; fcomplex A; fcomplex B; fcomplex coef[K*Q][K*Q]; Xunit32 ADDR; XIo_Out32(SYS_XCOEF_BEGIN,0X1243); for(m=0; m<K; m++) for(n=0; n<Q; n++) { for(i=0; i<K; i++) for(j=0; j<Q; j++) { sum.re=0; sum.im=0; for(k=0; k<LENGTH-Q+1; k++) { ADDR=(Q-1-n+k)*4; temp1.re=XIo_InFloat(RxAdRe+ ADDR); temp1.im=XIo_InFloat(RxAdIm+ ADDR); temp2.re= fpower(temp1, m); temp2.im=0; B=ffmul(temp1,temp2); B.im=-B.im; ADDR=(Q-1-j+k)*4; temp1.re=XIo_InFloat(RxAdRe+ ADDR); temp1.im=XIo_InFloat(RxAdIm+ ADDR); temp2.re= fpower(temp1, i); temp2.im=0; A=ffmul(temp1,temp2); sum=ffadd(sum,ffmul(A, B)); } coef[Q*m+n][Q*i+j]=sum; } } XIo_Out32(SYS_XCOEF_MID1,0X1244); }

 

 

 

0 Kudos
1 Solution

Accepted Solutions
phdwong
Explorer
Explorer
3,688 Views
Registered: ‎09-15-2011

ok now:smileyhappy:

View solution in original post

0 Kudos
2 Replies
phdwong
Explorer
Explorer
2,904 Views
Registered: ‎09-15-2011

We run the function void Test(void)

the complier are all rights

we read the SYS_XCOEF_BEGIN's value ,and can get the value 0x1243 

because we write the value using XIo_Out32(SYS_XCOEF_BEGIN,0X1243);

 

however we read the SYS_XCOEF_MID, the value is 0

if the for loop run over , it's will write the value 0x1244 using XIo_Out32(SYS_XCOEF_MID1,0X1244);

 

I use the XMD to check the stack, and it's not full

 

 

 

why the for loop cannot run at the XIo_Out32(SYS_XCOEF_MID1,0X1244)?

0 Kudos
phdwong
Explorer
Explorer
3,689 Views
Registered: ‎09-15-2011

ok now:smileyhappy:

View solution in original post

0 Kudos