Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/04/07 14:14
Read: times


 
#142761 - Runtime Computed Table??
Responding to: ???'s previous message
In the common scheme of today's microcontrollers with the program code contained in on-board FLASH and data stored into on-board RAM I would suggest that a run time computed CRC table is a bad trade off on the use of RAM versus FLASH. I would really recommend that you use a pre-computed table and directly embed it into your code space so that the you do not "waste" RAM which is the more scarce resource on almost all MCUs.

If you are interested I have used a scheme that uses a table lookup scheme for CRC computation that uses a very small look up table of some 32-bytes by doing table look-up on data nibbles (4-bits at a time) instead of using a byte at a time scheme. The performance gain over bit serial methods is still substantial and with the speed of many modern MCSs the method is very usable in cases where a huge table is not attractive. The typical CRC table for byte-at-a-time schemes eats up 512 bytes.

Here is C code for the nibble CRC algorithm:
//
//
// CRC table for implementing CRC16 with 0x1021 polynomial
//
//

__flash const unsigned int crc_table[16] =
{
     0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 
     0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 
}; 

//
//
// routine to calculate the CRC of a current value with a 
// new byte value. The new CRC result is returned.
//
//

unsigned int calc_crc(unsigned int crc, unsigned char data)
{
    crc = crc_table[((crc >> 12) ^ (data >> 4)) & 0x0F] ^ (crc << 4);
    crc = crc_table[((crc >> 12) ^ (data & 0x0F)) & 0x0F] ^ (crc << 4);
    return(crc);
}


Michael Karas


List of 23 messages in thread
TopicAuthorDate
How to create a crc table?            01/01/70 00:00      
   simple            01/01/70 00:00      
      RE: simple            01/01/70 00:00      
         I said it\'s simple            01/01/70 00:00      
            Thank you            01/01/70 00:00      
            Protocols            01/01/70 00:00      
               examples            01/01/70 00:00      
   Runtime Computed Table??            01/01/70 00:00      
      RE: Runtime...?            01/01/70 00:00      
      table is not necessary            01/01/70 00:00      
         Benchmark            01/01/70 00:00      
            I did benchmarks as such on AVR            01/01/70 00:00      
               Similar findings            01/01/70 00:00      
                  no beavers that I've tended to!!            01/01/70 00:00      
               not bitwise....            01/01/70 00:00      
            Better is a strong word            01/01/70 00:00      
               Also comment about SMBus PEC Code...            01/01/70 00:00      
   The Table            01/01/70 00:00      
   The Nibble Table for Poly 107            01/01/70 00:00      
   The formula            01/01/70 00:00      
   Have you seen this?            01/01/70 00:00      
      Now I have            01/01/70 00:00      
      Yes, that is a Key Document!            01/01/70 00:00      

Back to Subject List