CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Errors with PCD built-in crc functions

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

Errors with PCD built-in crc functions
PostPosted: Fri Oct 03, 2008 3:56 pm     Reply with quote

Hello,

PCD has built in-functions for PIC24F hardware crc engine. I found some errors and a difference to command despription in the compiler manual.

- In den manual examples, the below setup_crc is said to select the CRC16 polynomial:
Quote:
setup_crc (12, 5);
// CRC Polynomial is X16 + X12 + X5 + 1 or Polynomial = 1020h

As you can see from the assembly code, neither the polynomial length nor the value are set correct
Code:
    setup_crc(12, 5); // Polynomial 0x1021
032FE:  MOV.B   #21,W0L
03300:  MOV.B   W0L,642
03302:  MOV.B   #B,W0L
03304:  MOV.B   W0L,640


Using setup_crc (16,12, 5) achieves a correct length, but still a wrong polynomial. The correct code is
Code:
CRCXOR = 0x1021;
CRCCON = 0xf;


- The compiler manual tells, that crc_calc() respectively crc_calc8() can be used with a single word/byte argument. Apparently this mode is yet unsupported.

- crc_calc is always stuck in an endless loop when it starts the CRC calculation
Code:
0279A  A88640     bset.b 0x0640,#4 ; CRCGO
0279C  AF8640     btsc.b 0x0640,#4 ; CRCMPT (#6) should be tested instead
0279E  37FFFD     bra 0x00279a     ; loops forever


- Furthermore, there is a general problem with the CRC hardware, that an odd number of bytes can't be processed without an considerable overhead. See AN1148 for details.

Regards,
Frank
eoinoc



Joined: 30 Apr 2009
Posts: 16

View user's profile Send private message

PostPosted: Mon Oct 25, 2010 7:12 pm     Reply with quote

Does anyone have an update on this topic?

I did some testing with the built in functions in CCS and the result returned from the CRC function which uses the hardware CRC in the PIC24HJ and the answers dont appear to be correct infact the result always stays at the same value.

Is anyone willing to share some drivers for the on chip CRC generator ?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Oct 25, 2010 11:01 pm     Reply with quote

Besides the reported PCD bugs, I had another reason not to use the PIC24 hardware CRC unit. It's involving a considerable overhead for byte data with an odd byte count, as already mentioned. So I fell back to the table and shift register based CRC algorithms I used with other processors.

I didn't check again the PCD built-in CRC functions and don't know, if they have substantially changed since V4.097.
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Tue Oct 26, 2010 12:33 pm     Reply with quote

Just in case it's the issue these polynomials require seed values usually
0x0000 or 0xFFFF. Most often 0x0000 is used.

// CRC Polynomial is X16 + X12 + X5 + 1 or Polynomial = 1020h

this X16+X12+X5+1 is 1021h or 0b0001 0000 0010 0001 the set bits represent the power sequence 1 is x^0 so X^5 is in position 5 starting at zero. Did they perhaps calc X16+x12+x5+0 the true 1020h
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group