This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Confuse with 66AK's Cache operation

Hi, I am using 66AK, found some problem when sync global variable between BIOS tasks.

following is my code, please help to check it. Thanks a lot.

struct jsync_t Sync;    // Define a global value here, it has member width and height. 
struct jsync_t *pSync = NULL;

XDAS_Int32 main(void)
{
Task_Params serverParam;
Task_Params clientParam;
Task_Params readParam;

dbg("JPEG encoder start...\n");
pSync = &Sync;                         // Set a pointer to access it
//jEnableCache();
Cache_enable(Cache_Type_ALL); 
memset((void*)pSync, 0, sizeof(struct jsync_t));
pSync->param.alg = ENC_ALOG_JPEG;
pSync->param.fpb = 1;
pSync->param.height = PHT_DEFAULT_HEIGHT;               // set the member
pSync->param.width = PHT_DEFAULT_WIDTH;
Cache_wbAll();                                                                     // Write back to memory, and check it in ccs, if did not call this, value only available in L1D cache

if (DNUM == 0) {
/* Create encode task */
dbg("Create server Task\n");
Task_Params_init(&serverParam);
serverParam.stackSize = 0x4000;
Task_create((Task_FuncPtr)jServerTask, &serverParam, NULL);

dbg("Create Read Task\n"); 
Task_Params_init(&readParam);
readParam.stackSize = 0x4000;
Task_create((Task_FuncPtr)jReadTask, &readParam, NULL);
}

dbg("Create Client Task\n");
Task_Params_init(&clientParam);
clientParam.stackSize = 0x4000;
Task_create((Task_FuncPtr)jClientTask, &clientParam, NULL);

/* Call BIOS_start() */
printf("TI-BIOS Start, %d x %d, alg = %d\n", pSync->param.width, pSync->param.height, pSync->param.alg);   // print it is correct
BIOS_start();
}







void jServerTask(void)
{
int dspCnt;
int i;
struct jsync_t *p = &Sync;

// FOREVER {
// dbg("Server %d\n", p->param.alg ++);
// Task_sleep(1000);
// }

FOREVER {
for (i = 0; i < PHT_BLOCKS_PER_FILE; i ++) {
// find a free thread to encode
FOREVER { 
Cache_inv(&p->param, sizeof(struct jsync_param_t), Cache_Type_ALL, 1);
for (dspCnt = 0; dspCnt < MAX_DSP_CORES; dspCnt ++) {
if (p->param.status[dspCnt] == JSTS_FREE) {
dbg("Found a Free DSP, NUM = %d\n", dspCnt);
break;
}
}
if (dspCnt < MAX_DSP_CORES) 
break; 
Task_sleep(10);
}
// Set DSP to encode
//memcpy((void*)&p->inBuf[dspCnt * PHT_DEFAULT_FRAME_SIZE], 
// (const void*)&inBufAry[i % BMP_COUNT], PHT_DEFAULT_FRAME_SIZE); // copy a block to DSP
Cache_inv(&Sync.param, sizeof(struct jsync_param_t), Cache_Type_L1D, 1);
dbg("%d x %d, alg = %d\n", Sync.param.width, Sync.param.height, Sync.param.alg);           // Print is nothing, check in CCS, value is correct in memory, but not availabe in local "p" pointer

                                                                                                                                                   
jInitTestBmp((unsigned char*)p->inBuf);
//printf("Copy time: %.4f, fps = %.2f, %.2f MBps\n", time, 
// RIO_RGB_BLOCK_SIZE * 1.0 / RIO_RGB_FRAME_SIZE / time, 
// RIO_RGB_BLOCK_SIZE * 1.0 / time / 1024 / 1024); 
p->param.seq[dspCnt] = i;
p->param.status[dspCnt] = JSTS_BUSY; // start...
}
}
}