This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF52 RADIO CRC calculation method

address = 0xe7 0xe7 0xe7(3bytes),

dataLength=0x01(8bit),

S1>>PID=0x01(2bit);NO_ACK=0x00(1bit);

How to calculate CRC, I need software calculation, not hardware processing.

Thanks!

Parents
  • CRC format

    if (m_config_local.crc == RADIO_CRCCNF_LEN_Two)
    {
    NRF_RADIO->CRCINIT = 0xFFFFUL; // Initial value
    NRF_RADIO->CRCPOLY = 0x11021UL; // CRC poly: x^16+x^12^x^5+1
    }

    uint16_t crc16_compute(uint8_t const * p_data, uint32_t size, uint16_t const * p_crc)
    {
    uint16_t crc = (p_crc == NULL) ? 0xFFFF : *p_crc;

    for (uint32_t i = 0; i < size; i++)
    {
    crc = (uint8_t)(crc >> 8) | (crc << 8);
    crc ^= p_data[i];
    crc ^= (uint8_t)(crc & 0xFF) >> 4;
    crc ^= (crc << 8) << 4;
    crc ^= ((crc & 0xFF) << 4) << 1;
    }

    return crc;
    }

    What should para p_data enter?

Reply
  • CRC format

    if (m_config_local.crc == RADIO_CRCCNF_LEN_Two)
    {
    NRF_RADIO->CRCINIT = 0xFFFFUL; // Initial value
    NRF_RADIO->CRCPOLY = 0x11021UL; // CRC poly: x^16+x^12^x^5+1
    }

    uint16_t crc16_compute(uint8_t const * p_data, uint32_t size, uint16_t const * p_crc)
    {
    uint16_t crc = (p_crc == NULL) ? 0xFFFF : *p_crc;

    for (uint32_t i = 0; i < size; i++)
    {
    crc = (uint8_t)(crc >> 8) | (crc << 8);
    crc ^= p_data[i];
    crc ^= (uint8_t)(crc & 0xFF) >> 4;
    crc ^= (crc << 8) << 4;
    crc ^= ((crc & 0xFF) << 4) << 1;
    }

    return crc;
    }

    What should para p_data enter?

Children
Related