完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
板子:M471
例程:CRC_CCITT main函数部分 /*---------------------------------------------------------------------------------------------------------*/ /* MAIN function */ /*---------------------------------------------------------------------------------------------------------*/ int main(void) { const uint16_t u16CRCSrcPattern[] = {0x3231, 0x3433, 0x3635, 0x3837}; uint32_t i, u32TargetChecksum = 0xA12B, u32CalChecksum = 0; /* Init System, peripheral clock and multi-function I/O */ SYS_Init(); /* Init UART0 for printf */ UART0_Init(); printf("\n\nCPU @ %d Hz\n", SystemCoreClock); printf("+---------------------------------------------+\n"); printf("| CRC-CCITT Polynomial Mode Sample Code |\n"); printf("+---------------------------------------------+\n\n"); printf("# Calculate [0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38] CRC-CCITT checksum value.\n"); printf(" - Seed value is 0xFFFF \n"); printf(" - CPU write data length is 16-bit \n"); printf(" - Checksum complement disable \n"); printf(" - Checksum reverse disable \n"); printf(" - Write data complement disable \n"); printf(" - Write data reverse disable \n"); printf(" - Checksum should be 0x%X \n\n", u32TargetChecksum); /* Configure CRC controller for CRC-CCITT CPU mode */ CRC_Open(CRC_CCITT, 0, 0xFFFF, CRC_CPU_WDATA_16); /* Start to execute CRC-CCITT operation */ for(i = 0; i < sizeof(u16CRCSrcPattern) / sizeof(u16CRCSrcPattern[0]); i++) { CRC_WRITE_DATA((u16CRCSrcPattern)); } /* Get CRC-CCITT checksum value */ u32CalChecksum = CRC_GetChecksum(); printf("CRC checksum is 0x%X ... %s.\n", u32CalChecksum, (u32CalChecksum == u32TargetChecksum) ? "PASS" : "FAIL"); /* Disable CRC function */ CLK_DisableModuleClock(CRC_MODULE); while(1); } |
|
相关推荐
1个回答
|
|
sp; *//---------------------------------------------------------------------------------------------------------*/int main(void){ /*Initialize system*/ SystemInit(); /*Initialize UART port*/ UART0_Init(); /*Enable CRC clock*/ CLK_EnableModuleClock(CRC_MODULE); /* Set CRC-CCITT with no reflection */ CRC_Open(CRC_CCITT, 0, CRC_CPU_WDATA_16); /*Start to calculate CRC*/ uint32_t result = CRC_GetChecksum(CRC_CHANNEL_0, data, dataSize); /*Print CRC value to UART*/ printf("CRC value: %08Xrn", result); /*Disable CRC clock*/ CLK_DisableModuleClock(CRC_MODULE); while(1){ } return 0;}
|
|
|
|
只有小组成员才能发言,加入小组>>
3322 浏览 9 评论
3000 浏览 16 评论
3497 浏览 1 评论
9070 浏览 16 评论
4090 浏览 18 评论
1191浏览 3评论
613浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
603浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2341浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1899浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-28 23:03 , Processed in 1.260846 second(s), Total 78, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (威廉希尔官方网站 图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号