CRC verification is used in stm32 and C #.

Source: Internet
Author: User
/* Enable CRC clock */rcc_ahbperiphclockcmd (rcc_ahbperiph_crc, enable); // javascrcu32 CRC32 (u8 * pbuf, 2010nsize) {u32 Index = 0; crc_resetdr (); // reset CRC for (Index = 0; index <nsize; index ++) {CRC-> DR = (u32) pbuf [Index];} return (CRC-> Dr );}

// Example of C # static readonly uint [] crc32table = {0x00000000, 0x04c11db7, clerk, clerk, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, clerk, 0x350c9b64, 0x31cd86d3, expires, 0x0000796c2, expires, 0x6a1936c8, 0x6ed82b7f, expires, 0x745e66cd, hour, 0x9ce2ab57, 0x91a18d8e, 0x95609039, hour, 0xbaea46ef, hour, 0xa4ad16ea, hour, 0xd4326d90, hour, 0xddb056fe, 0xd9714b49, primary, 0xc3f706fb, 0xceb42022, 0xca753d95, primary, 0x34867077, primary, primary, 0x39c556ae, primary, 0x23431b1c, primary, 0x2ac12072, 0x128e9dcf, 0x164f8078, primary, 0x1fcdbb16, primary, 0x71159069, 0x75d48dde, primary, 0x66d0fb02, primary, primary, primary, 0x53dc6066, 0x4d9b3063, primary, primary, 0x40d816ba, primary, 0xbb60adfc, primary, 0x87ee0df6, 0x99a95df3, expires, expires, 0x94ea7b2a, expires, 0xe4750050, expires, 0xfa325055, expires, 0xdc3abded, 0xd8fba05a, 0x690ce0ee, listen, 0x608edb80, 0x644fc637, 0x7a089632, 0x7ec98b85, clerk, 0x46863638, clerk, 0x5500000e4, clerk, clerk, 0x21dc2629, clerk, primary, 0x32d850f5, primary, primary, 0x0315d626, primary, 0x1011a0fa, primary, 0x19939b94, primary, 0xeba91bbc, 0xef68060b, values, numbers, 0xc423cd6a, 0xc0e2d0dd, numbers, 0xa1_dd7b, numbers, 0x9ff77d71, 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, 0x5d8a9099, expires, 0x43gj09c, expires, 0x61043093, 0x65c52d24, hour, 0x155a565e, 0x18197087, hour, 0x0fdc1bec, hour, 0x2056cd3a, hour, hour, 0xc5a92679, 0xc1683bce, primary, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, primary, 0xea23f0af, 0xeee2ed18, primary, 0x9abc8bd5, primary, values, numbers, 0xafb010b1, 0xab710d06, numbers, 0xa2f33668, 0xbcb4666d, 0xb8757133, numbers, numbers}; // public static uint crc32software (byte [] pdata, int length) {uint nreg; // CRC register uint ntemp = 0; int I, n; nreg = 0 xffffffff; // For (n = 0; n <length; n ++) {nreg ^ = (uint) pdata [N]; for (I = 0; I <4; I ++) {ntemp = crc32table [(nreg> 24) & 0xff]; // get a byte and look up the table nreg <= 8; // discard the computed header A byte nreg ^ = ntemp; // different from the calculation result of the previous byte or} return nreg ;}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.