Optimizing CRC16 routine.


Results 1 to 20 of 20

Threaded View

  1. #8
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default

    ... <snip> ... I'm using TMR1 to measure the execution time of the routine ... <snip> ...
    Could that be a problem? Do you have anything similar to the MPLAB Simulator Stopwatch?

    ... <snip>... This time I got 1533 cycles ... <snip> ...
    My goodness, that doesn't sound quite right. That's close to what you got when you were processing nine bytes. Could there be a problem with the method you're using to count cycles?

    I would expect you to get code similar to the assembler code generated from my BoostC "Do/While" loop;

    Code:
      crcword ^= work; i = 8;   //
    0040  0845  	MOVF crc16_00000_arg_work, W
    0041  06B7  	XORWF gbl_crcword, F
    0042  3008  	MOVLW 0x08
    0043  00C6  	MOVWF crc16_00000_1_i
    
      do {                      //
    0044        label5
    
        crcword >>= 1;          //
    0044  36B8  	LSRF gbl_crcword+D'1', F
    0045  0CB7  	RRF gbl_crcword, F
    
        if(status.C)            //
    0046  1C03  	BTFSS gbl_status,0
    0047  284C  	GOTO	label6
    004C        label6
    
          crcword ^= 0x0A01;    //
    0048  3001  	MOVLW 0x01
    0049  06B7  	XORWF gbl_crcword, F
    004A  300A  	MOVLW 0x0A
    004B  06B8  	XORWF gbl_crcword+D'1', F
    
      } while(--i);             //
    004C  03C6  	DECF crc16_00000_1_i, F
    004D  1D03  	BTFSS STATUS,Z
    004E  2844  	GOTO	label5
    }
    Last edited by Mike, K8LH; - 16th January 2011 at 18:53.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts