Embedded/펌웨어?
stm32f05xx CRC
EHOzlO
2019. 4. 16. 14:12
내부 CRC 사용
CRC32/MPEG-2 방식
소스)
- 함수
uint32_t crc_compute(uint32_t * start_addr, uint32_t size)
{
uint32_t crc_code;
uint32_t i = 0;
// Enable CRC
__HAL_RCC_CRC_CLK_ENABLE();
CRC->CR |= CRC_CR_RESET;
while(i < size)
{
CRC->DR = start_addr[i];
i++;
}
crc_code = CRC->DR;
// Disable CRC
__HAL_RCC_CRC_CLK_DISABLE();
return crc_code;
}
- 사용
uint32_t tbuf[2] = {0x1A2B3C4D, 0x1A2B3C4D};
tempp = crc_compute(&tbuf, 2);
-->tempp 값 = 0xF7461111