View previous topic :: View next topic |
Author |
Message |
mce91
Joined: 18 Aug 2005 Posts: 3 Location: Paris
|
16F876 & SHT71 |
Posted: Thu Aug 18, 2005 4:15 pm |
|
|
Hello
I has fought for 2 days to make the calculation of the CRC between a SHT71 and a PIC16F876.
Even with the scope note from sensirion I do not arrive there
http://www.sensirion.com/images/getFile?id=80
The calculation of the CRC at sensirion is not standard. I found at DALLAS a scope note (27) which uses the same principle but within sight of the table of CRC from Dallas the result is different.
My crontrainte is not to be able to use a table of CRC (no more place available)
If you have ideas or solutions I am taking
@+
Michel |
|
|
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
Re: 16F876 & SHT71 |
Posted: Thu Aug 18, 2005 4:20 pm |
|
|
mce91 wrote: |
My crontrainte is not to be able to use a table of CRC (no more place available)
Michel |
If that is your only problem, then go upgrade your PIC16F876 to a PIC18F252. You'll now have double the space. |
|
|
mce91
Joined: 18 Aug 2005 Posts: 3 Location: Paris
|
Re: 16F876 & SHT71 |
Posted: Thu Aug 18, 2005 4:33 pm |
|
|
MikeValencia wrote: | mce91 wrote: |
My crontrainte is not to be able to use a table of CRC (no more place available)
Michel |
If that is your only problem, then go upgrade your PIC16F876 to a PIC18F252. You'll now have double the space. |
using another PIC is not the solution ... |
|
|
mce91
Joined: 18 Aug 2005 Posts: 3 Location: Paris
|
16F876 & SHT71 |
Posted: Fri Aug 19, 2005 5:21 pm |
|
|
After lot of hours ... the solution by my self !!!
unsigned int8 crc_sht (char *data,unsigned char oldcrc, unsigned int8 length)
{
unsigned int8 i=0, ibit=0, c=0, crc;
#bit crc4 = crc.4
#bit crc5 = crc.5
#bit crc7 = crc.7
#bit c7 = c.7
crc=oldcrc;
data++;
for (i = 0; i < length; i++, data--)
{
c = *data;
for (ibit = 0; ibit < 8; ibit++)
{
if (c7 == crc7)
{
crc = crc << 1;
crc = crc & 0xFE;
}
else
{
crc = crc << 1;
crc4 = ~(crc4) ;
crc5 = ~(crc5) ;
crc = crc | 0x01;
}
c = c << 1;
}
}
return crc;
} |
|
|
|