AnsweredAssumed Answered

CRC Peripheral Driver API usage

Question asked by chiara.bizzotto on Nov 3, 2016
Latest reply on Dec 13, 2016 by chiara.bizzotto

Hi! I'm trying to calculate the crc of a buffer. I've tried following the instructions provided in the Help in CCES and also i've tried running the snipped code from  CCES Examples. In both cases I'm facing the same problem: the code keep remaining stuck inside the while loop because adi_crc_IsCrcInProgress never returns false.

 

  /* CRC Return code */
ADI_CRC_RESULT eResult;
/* CRC value */
uint32_t Crc32Value;

/* Initialize managed drivers and/or services */

adi_initComponents();

// putting some values different from zero in the buffer
DataBuf[0] = 32;
DataBuf[100] = 43;
DataBuf[3] = 2;

/* Open a CRC device instance */
eResult = adi_crc_Open (0, &CrcDevMem[0], ADI_CRC_DMA_MEMORY_SIZE, &hCrcDev);

/* Reset CRC registers */
eResult = adi_crc_StopReset (hCrcDev, true, true);

/* Set CRC polynomial */
eResult = adi_crc_SetPolynomialVal (hCrcDev, 3988292384);

/* Sets data mirroring configuration */
eResult = adi_crc_SetDataMirror (hCrcDev, ADI_CRC_MIRROR_NONE);

/* Enable DMA mode for CRC */
eResult = adi_crc_EnableDmaMode (hCrcDev, true);

/* Register callback function if required */
eResult = adi_crc_RegisterCallback (hCrcDev, CrcCallback, hCrcDev);

/* Set CRC operating mode as Memory Scan Compute Compare */
eResult = adi_crc_SetOperatingMode (hCrcDev, ADI_CRC_MODE_SCAN_COMPUTE_COMPARE);

/* Set CRC data word count and Reload word count */
eResult = adi_crc_SetDataCount (hCrcDev, 512, 0);

/*
* Set the expected CRC32 value.
* Pass this value as 0 if the CRC value for the the data stream is unknown.
* The CRC device will return a CRC data compare error at the end of
* CRC operation. Ignore this error and read the CRC final result register.
* This register holds the CRC value calculated for the data stream.
*/
eResult = adi_crc_SetExpectedVal (hCrcDev, 0);

/* Set the current CRC status flag as CRC operation in progress */
bCrcInProgress = true;

/* Submit CRC buffer to Scan-Compute-Compare */
eResult = adi_crc_DmaMemFillScan (hCrcDev, &DataBuf[0], 512);

/* Wait until the CRC operation is complete or CRC error */
while (bCrcInProgress && (bCrcDataCompareErr == false) && (bCrcDmaErr == false))
{
/*
* Query the current status of CRC operation if operating in non-blocking mode
* This function call is not required for callback mode
*/
eResult = adi_crc_IsCrcInProgress (hCrcDev, &bCrcInProgress);
}

/*
* Read the final CRC result if the CRC value for the buffer is yet to be calculated
* This function also resets the registers that hold the final and intermediate CRC values
*/
eResult = adi_crc_GetFinalCrcVal (hCrcDev, &Crc32Value);

/* Handle CRC error, if any */

/* Close CRC Device */
eResult = adi_crc_Close (hCrcDev);

The callback function simply puts the flags to true/false if corresponding events occurs but it never gets called.

What I don't understand is that if I put a delay after adi_crc_DmaMemFillScan and I just call adi_crc_GetFinalCrcVal without the while loop, Crc32Value is correctly set.

 

I'm using BF707 in BLIP2 platform.

 

Am I using the APIs wrong? Is there some further setting I'm missing?

Thanks for your help

 

Chiara

Outcomes