kindly tell me any efficient code for generating CRC for 40 bytes data I am using the modulo 2 division method.
with thanks, karthik.
Most implementations that are table-based comes with two compilation options.
Either use a pre-built table (already there in the source code) or call a function to built the table.
Obviously, an embedded target with very little RAM should choose to use the pre-built table but placing it in the code space.
Google will show many, many implmenetations.
The documentation (or search on this forum for how to place variables in code) will answer how to place the table where it doesn't consume RAM.
An improvement right here
int i,j; // signed 16 bit variable
40 byte and 8 bits
try unsigned char
Take your code write a PC program that creates a table. Then copy that to your project.
I am assuming you need faster code. How much faster?
"But I think his question ..."
I think that some means of viewing thread chaining/hierarchy would be high on most people's list of forum enhancements.
But I think his question about tables was referring to the code he's seen - and wondering how to implement it on his target?
That's not (necessarily) true.
The truth is that a skilled and experienced assembler programmer could probably speed it up a little.
In inexperiences and/or unskilled hands, assembler may well be worse than 'C'!
"He said he's seen methods that use tables..."
I am referring to the code he said he is using, not the code he's seen.
He said he's seen methods that use tables...
"How to store the table ..."
What table? The code you posted calculates the CRC one bit at a time and does not use or need a table.
"finally i am using this code...."
That code doesn't use a table.
How to store the table code space Please read the manual
I am new to embedded then the first thing you should do is to work through (I did not say 'read') the Getting started Guide.
Erik
How to store the table code space I am new to embedded...kindly help me......
finally i am using this code....
int Calc_CRC(unsigned char b[], unsigned int CRC,int nBytes) { bit carry; int i,j; for(j=0;j<nBytes;j++) { carry=0; CRC ^= b[j] & 0xFF; for (i=0; i<8; i++) { carry = CRC & 0x0001; CRC>>=1; if (carry) { CRC ^= GP; } } } return CRC; }
But the table contain constants, so you can prebuild it and store in the code space.
i am using CRC16(modulo2).But table method how to implement it..In net I have seen table they have created for 256 bytes.But my internal memory size is 256...
View all questions in Keil forum