各位大神:
请教一下,测试TMS570LS3137的crc自动模式,发现BUSY位一直为1, PSA sector signature寄存器没有值,PsaSig寄存器和CRC_Value寄存器的低8位不匹配,问题出在哪呢?
/* USER CODE BEGIN (2) */ #define FRAME_COUNT 0x1 #define ELEMENT_COUNT 0x1 #define D_SIZE 8 g_dmaCTRL g_dmaCTRLPKT0, g_dmaCTRLPKT1; // dma control packet configuration stack int main(void) { /* USER CODE BEGIN (3) */ // uint64 u64Signature = 0U; uint64 result_crc = 0U; _enable_IRQ(); // uint32_t CRC1_Ref[2] = {0x5F7EAE33, 0x6233774E}; uint64 crc_test_value = 0x8DF8A32C74B91F3E; // uint16 tx_data[D_SIZE] = {0x1111,0x2222,0x3333,0x4444,0x5555,0x6666,0x7777,0x8888}; // uint64 *p = &crc_test_value; crcInit(); result_crc = crc_update_word(0U, crc_test_value); // result_crc = calc_crc64(p,1); printf("%llx \n",result_crc); crcREG->PCOUNT_REG1= FRAME_COUNT * ELEMENT_COUNT; crcREG->SCOUNT_REG1 = 1; crcEnableNotification(crcREG,1); dmaEnable(); g_dmaCTRLPKT0.SADD = (uint32_t)(&(result_crc)); //g_dmaCTRLPKT0.SADD = (uint32_t)0x08000FE8; //address of variable result_crc which holds the pre-determined CRC value. // g_dmaCTRLPKT0.SADD = (uint32_t)(&CRC1_Ref[0]); g_dmaCTRLPKT0.DADD = (uint32_t)(&(crcREG->REGL1)); g_dmaCTRLPKT0.CHCTRL = 0; g_dmaCTRLPKT0.FRCNT = FRAME_COUNT; g_dmaCTRLPKT0.ELCNT = ELEMENT_COUNT; g_dmaCTRLPKT0.ELDOFFSET = 0; g_dmaCTRLPKT0.ELSOFFSET = 0; g_dmaCTRLPKT0.FRDOFFSET = 0; g_dmaCTRLPKT0.FRSOFFSET = 0; g_dmaCTRLPKT0.PORTASGN = 4; g_dmaCTRLPKT0.RDSIZE = ACCESS_64_BIT; g_dmaCTRLPKT0.WRSIZE = ACCESS_64_BIT; g_dmaCTRLPKT0.TTYPE = FRAME_TRANSFER; g_dmaCTRLPKT0.ADDMODERD = ADDR_FIXED; g_dmaCTRLPKT0.ADDMODEWR = ADDR_FIXED; g_dmaCTRLPKT0.AUTOINIT = AUTOINIT_OFF; // setting dma control packets for receive dmaSetCtrlPacket(DMA_CH0, g_dmaCTRLPKT0); // dmaReqAssign(DMA_CH0, DMA_REQ26); dmaSetChEnable(DMA_CH0 ,DMA_SW); g_dmaCTRLPKT1.SADD = (uint32_t)(&(crc_test_value)); //g_dmaCTRLPKT1.SADD = (uint32_t)0x08000FF0;//address of crc_test_value from where the memory area to be verified. // g_dmaCTRLPKT1.SADD = (uint32_t)tx_data; /* source address */ g_dmaCTRLPKT1.DADD = (uint32_t)(&(crcREG->PSA_SIGREGL1)); g_dmaCTRLPKT1.CHCTRL = 0; g_dmaCTRLPKT1.FRCNT = FRAME_COUNT; g_dmaCTRLPKT1.ELCNT = ELEMENT_COUNT; g_dmaCTRLPKT1.ELDOFFSET = 0; g_dmaCTRLPKT1.ELSOFFSET = 0; g_dmaCTRLPKT1.FRDOFFSET = 0; g_dmaCTRLPKT1.FRSOFFSET = 0; g_dmaCTRLPKT1.PORTASGN = 4; g_dmaCTRLPKT1.RDSIZE = ACCESS_64_BIT; g_dmaCTRLPKT1.WRSIZE = ACCESS_64_BIT; g_dmaCTRLPKT1.TTYPE = FRAME_TRANSFER; g_dmaCTRLPKT1.ADDMODERD = ADDR_FIXED; g_dmaCTRLPKT1.ADDMODEWR = ADDR_FIXED; g_dmaCTRLPKT1.AUTOINIT = AUTOINIT_OFF; // setting dma control packets for receive dmaSetCtrlPacket(DMA_CH1, g_dmaCTRLPKT1); dmaSetChEnable(DMA_CH1, DMA_SW); /** while( crcREG->BUSY & 1ul ) { } u64Signature = crcGetSectorSig(crcREG, CRC_CH1); crcREG->STATUS = CRC_CH1_CC; if(u64Signature != result_crc){ printf("wrong!,result_crc is %llx,u64Signature is %llx",result_crc,u64Signature); }else{ printf("right!"); } */ // printf("%llx \n",u64Signature); // while(1); /* USER CODE END */ return 0; }
uint64 crc_update_word(uint64 crc, uint64 data) { int i, j; uint64 nextCrc = 0; // for i in 63 to 0 loop for(i = 63; i >= 0; i--) { // NEXT_CRC_VAL(0) := CRC_VAL(63) xor DATA(i); nextCrc = (nextCrc & (uint64)0xfffffffffffffffe) | ((crc >> 63) ^ (data >> i)); // for j in 1 to 63 loop for(j = 1; j < 64; j++) { //case j is // when 1|3|4 => if(j == 1 || j == 3 || j == 4) { // NEXT_CRC_VAL(j) := CRC_VAL(j - 1) xor CRC_VAL(63) xor DATA(i); nextCrc = (nextCrc & ~((uint64)1 << j)) | ((((crc >> (j-1)) ^ (crc >> 63) ^ (data >> i)) & 1) << j); } else { // when others => // NEXT_CRC_VAL(j) := CRC_VAL(j - 1); nextCrc = (nextCrc & ~((uint64)1 << j)) | (((crc >> (j-1)) & 1) << j); } // end case; } // end loop; crc = nextCrc; } // end loop return crc; }