CRC設定上開這兩個
CRC_WDATA_RVS
CRC_CHECKSUM_RVS
就可以跑出0x37DD的數值了
程式都幫你寫好了,你試看看吧
int main()
{
const uint8_t acCRCSrcPattern[] = {0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38};
uint32_t i,u32TargetChecksum = 0x37DD, u32CalChecksum = 0;
/* Unlock protected registers */
SYS_UnlockReg();
SYS_Init();
/* Lock protected registers */
SYS_LockReg();
/* Init UART0 to 115200-8n1 for print message */
UART_Open(UART0, 115200);
Bsp_Crc_Controller_Reset();
Bsp_Crc_Module_Enable();
CRC_Open(CRC_16, CRC_WDATA_RVS|CRC_CHECKSUM_RVS, 0xFFFF, CRC_CPU_WDATA_8);
for(i = 0; i < sizeof(acCRCSrcPattern); i++)
{
CRC_WRITE_DATA((acCRCSrcPattern[i] & 0xFF));
}
/* Get CRC-8 checksum value */
u32CalChecksum = CRC_GetChecksum();
printf("CRC checksum is 0x%X ... %s.\n", u32CalChecksum, (u32CalChecksum == u32TargetChecksum) ? "PASS" : "FAIL");
while(1);
}
|