Reply by mall...@yahoo.co.in August 3, 20092009-08-03
Hi!

I am trying to use Cache in BF532 Processor.....I have used the example codes given with EE-271...I am Pating the code here and attaching for reference....

My program is strucking after running Config_D_Cache( ).....

The program like this....

#define DCPLB_CNT 1
//#define ICPLB_CNT 9
section("sdram0")
unsigned char a[4096];
section("sdram0")
unsigned char b[4096];
section("sdram0")
unsigned int c[4096];

//4M Page SIze + CPLB_VALID + CPLB_USER_WR + CPLB_SUPV_WR + CPLB_USER_RD
//CPLB_DIRTY + CPLB_L1_CHBL
section("L1_data")
u32 D_cplb_data[DCPLB_CNT] = {0x3D01F} ;

section("L1_data")
u32 D_cplb_addr[DCPLB_CNT] = {0x0} ;

section("L1_code")
void test_add(unsigned char a[],unsigned char b[])
{
int i;
for(i=0; i<4096; i++)
c[i] = a[i] + b[i];

}

/********************************************/
/* Clear the CYCLES and CYCLES2 registers */
/********************************************/
void StartProfiling ()
{
static u32 zeroInit = 0;

asm ("CYCLES = %0;"::"d"(zeroInit));
asm ("CYCLES2 = %0;"::"d"(zeroInit));
}
/********************************************/
/* Read the CYCLES and CYCLES2 registers */
/* profileInfoLow <- CYCLES */
/* profileInfoHigh <- CYCLES2 */
/********************************************/
void EndProfiling (volatile u32 *profileInfoLow, volatile u32 *profileInfoHigh)
{
asm ("%0 = CYCLES;":"=d"(*profileInfoLow));
asm ("%0 = CYCLES2;":"=d"(*profileInfoHigh));
}

volatile u32 decLow, decHigh;

int main( void )
{
/* Begin adding your custom code here */
unsigned char t1,t2,t3,t4;
unsigned int y1,y2,y3,y4,i;

for(i=0; i<4096; i++)
{
a[i] = 2;
b[i] = 2;
}
Config_D_Cache(D_cplb_addr,D_cplb_data,DCPLB_CNT, 1 );
/********************************************/
/* Clear the CYCLES and CYCLES2 register */
/********************************************/
StartProfiling ();
for(i=0; i<4096; i++)
test_add(a,b);
/********************************************/
/* Read back the CYCLES & CYCLES2 register */
/********************************************/
EndProfiling (&decLow, &decHigh);

/****************************/
/* Print the Cycle Count */
/****************************/
printf("\n The cycle count is %u: ",decLow);

return 0;
}
Any help will be helpful to me.......