This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is CRC32_ENABLED in hardware or software for nrf52832?

Hej!

I see that the CRC block is used in the Radio under section 23.6 of nRF52832_PS_v1.4.pdf. Also, I noticed that the CRC32_ENABLED is only enabled in the bootloader's sdk_config.h for DFU boot validation using crc32_compute().

// <q> CRC32_ENABLED - crc32 - CRC32 calculation routines
#ifndef CRC32_ENABLED
#define CRC32_ENABLED 1
#endif

My question is that my Application also needs to call crc32_compute() for this should I have #define CRC32_ENABLED 1 in the application's sdk_config.h?
I couldn't find suitable documentation to understand if CRC block is available in the hardware of nRF52832 or if it is software based on the SDK17.1.0 library?

Please help me understand this better.

Thanks,
Tilak

Parents
  • /**@brief Function for calculating CRC-32 in blocks.
     *
     * Feed each consecutive data block into this function, along with the current value of p_crc as
     * returned by the previous call of this function. The first call of this function should pass NULL
     * as the initial value of the crc in p_crc.
     *
     * @param[in] p_data The input data block for computation.
     * @param[in] size   The size of the input data block in bytes.
     * @param[in] p_crc  The previous calculated CRC-32 value or NULL if first call.
     *
     * @return The updated CRC-32 value, based on the input supplied.
     */
    uint32_t crc32_compute(uint8_t const * p_data, uint32_t size, uint32_t const * p_crc);
    
    
    uint32_t crc32_compute(uint8_t const * p_data, uint32_t size, uint32_t const * p_crc)
    {
        uint32_t crc;
    
        crc = (p_crc == NULL) ? 0xFFFFFFFF : ~(*p_crc);
        for (uint32_t i = 0; i < size; i++)
        {
            crc = crc ^ p_data[i];
            for (uint32_t j = 8; j > 0; j--)
            {
                crc = (crc >> 1) ^ (0xEDB88320U & ((crc & 1) ? 0xFFFFFFFF : 0));
            }
        }
        return ~crc;
    }

    I've copied the declaration with docs, and the definition of crc32_compute(), as you can see it's a SW implementation.
    The radio has a HW CRC block, but it's not available for the CPU to use. 

Reply
  • /**@brief Function for calculating CRC-32 in blocks.
     *
     * Feed each consecutive data block into this function, along with the current value of p_crc as
     * returned by the previous call of this function. The first call of this function should pass NULL
     * as the initial value of the crc in p_crc.
     *
     * @param[in] p_data The input data block for computation.
     * @param[in] size   The size of the input data block in bytes.
     * @param[in] p_crc  The previous calculated CRC-32 value or NULL if first call.
     *
     * @return The updated CRC-32 value, based on the input supplied.
     */
    uint32_t crc32_compute(uint8_t const * p_data, uint32_t size, uint32_t const * p_crc);
    
    
    uint32_t crc32_compute(uint8_t const * p_data, uint32_t size, uint32_t const * p_crc)
    {
        uint32_t crc;
    
        crc = (p_crc == NULL) ? 0xFFFFFFFF : ~(*p_crc);
        for (uint32_t i = 0; i < size; i++)
        {
            crc = crc ^ p_data[i];
            for (uint32_t j = 8; j > 0; j--)
            {
                crc = (crc >> 1) ^ (0xEDB88320U & ((crc & 1) ? 0xFFFFFFFF : 0));
            }
        }
        return ~crc;
    }

    I've copied the declaration with docs, and the definition of crc32_compute(), as you can see it's a SW implementation.
    The radio has a HW CRC block, but it's not available for the CPU to use. 

Children
No Data
Related