French wine, French cheese, French people...
[?]
I love France, probably is the country where I'll go again in my holiday...

Vasile

On Tue, Dec 14, 2010 at 11:28 PM, jfm68 <[email protected]> wrote:

> hi all,
> I'm not then inventor of that CRC, i juste adapte it to jal.
> It is the algoritm crc that DALLAS semiconductor compute for the 1-wire
> protocole.
> see crc section of :
> http://datasheets.maxim-ic.com/en/ds/DS18B20.pdf
> ----
> "CRC GENERATION
> CRC bytes are provided as part of the DS18B20's 64-bit ROM code and in the
> 9th
> byte of the scratchpad
> memory. The ROM code CRC is calculated from the first 56 bits of the ROM
> code and is contained in the
> most significant byte of the ROM. The scratchpad CRC is calculated from the
> data stored in the
> scratchpad, and therefore it changes when the data in the scratchpad
> changes. The CRCs provide the bus
> master with a method of data validation when data is read from the DS18B20.
> To verify that data has
> been read correctly, the bus master must re-calculate the CRC from the
> received data and then compare
> this value to either the ROM code CRC (for ROM reads) or to the scratchpad
> CRC (for scratchpad reads).
> If the calculated CRC matches the read CRC, the data has been received
> error free. The comparison of
> CRC values and the decision to continue with an operation are determined
> entirely by the bus master.
> There is no circuitry inside the DS18B20 that prevents a command sequence
> from proceeding if the
> DS18B20 CRC (ROM or scratchpad) does not match the value generated by the
> bus master.
>
> The equivalent polynomial function of the CRC (ROM or scratchpad) is:
> CRC = X8
> + X5
> + X4
> + 1
> The bus master can re-calculate the CRC and compare it to the CRC values
> from the DS18B20 using the
> polynomial generator shown in Figure 9. This circuit consists of a shift
> register and XOR gates, and the
> shift register bits are initialized to 0. Starting with the least
> significant bit of the ROM code or the least
> significant bit of byte 0 in the scratchpad, one bit at a time should
> shifted into the shift register. After
> shifting in the 56th bit from the ROM or the most  significant bit of byte
> 7 from the scratchpad, the
> polynomial generator will contain the re-calculated CRC. Next, the 8-bit
> ROM code or scratchpad CRC
> from the DS18B20 must be shifted into the circuit. At this point, if the
> re-calculated CRC was correct, the
> shift register will contain all 0s. Additional information about the Maxim
> 1-Wire cyclic redundancy check"
> ----
> if somebody has understand something after that !!! bravo
>
> my loop test juste the value of crc that the ds1820 has send and compute
> itself.
> If you want to compute the crc value of nnbytes with this algorithm,
> perhaps the loop will do the job !
>
> test it, i have not time yet....but i will be very happys to use a
> crc_libs, of course ;-)
>
> -- not industrial standart procedure ;-)-
> procedure d1w_read_byte_with_CRC( byte in nbre_byte, byte out GOOD_crc ) is
>
>  var byte bb = 0, n = 0 , crcbyte = 0     -- ! crcbyte must be set to 0
>  var bit  bb_bit0 at bb : 0
>  var bit  crcbyte_bit0 at crcbyte : 0 , crcbyte_bit2 at crcbyte : 2
>  var bit  crcbyte_bit3 at crcbyte : 3 , crcbyte_bit7 at crcbyte : 7
>  var bit  crcbit
>
> for nbre_byte loop             -- 8 bytes for readrom ID, 9 bytes for read
> temp
>
>    d1w_read_byte( bb )
>
>  n = n + 1                             -- čne byte
>  if n == 1 then d1 = bb end if            --  note d1 to d9 are globals var
>  if n == 2 then d2 = bb end if            --
>  if n == 3 then d3 = bb end if            --
>  if n == 4 then d4 = bb end if            --
>  if n == 5 then d5 = bb end if
>  if n == 6 then d6 = bb end if
>  if n == 7 then d7 = bb end if
>  if n == 8 then d8 = bb end if
>  if n == 9 then d9 = bb end if
>
> -- ---calcul  of crc---------------
>  for 8 loop
>  crcbit = crcbyte_bit0 ^ bb_bit0
>  crcbyte = crcbyte >> 1
>  crcbyte_bit7 = crcbit
>  crcbyte_bit2 = crcbyte_bit2 ^ crcbit
>  crcbyte_bit3 = crcbyte_bit3 ^ crcbit
>  bb = bb >> 1
>  end loop
> -- ---------------------------------
> end loop
> if d5==0x_FF & d6==0x_FF & d7==0x_FF & d8==0x_FF & d9==0x_FF  then   --
>  control
>  crcbyte = 1         -- probe is not present, all read to 1 == 0x_FF
>  d1=198              -- reset temp with error scale 99°c
> end if
>
> if crcbyte == 0 then
>  GOOD_crc = true
>  else
>  GOOD_crc = False
> end if  -- crcbyte must be 0 for crc without error
> end procedure
>
> good luke
>
>
> jean Marchaudon
>
>
>
>
>
> ----- Original Message ----- From: "funlw65(Vasi)" <[email protected]>
> To: "jallib" <[email protected]>
> Sent: Tuesday, December 14, 2010 9:04 PM
>
> Subject: [jallib] Re: One wire library
>
>
> I think it wouldn't be helpful (is device related and a some more
> accurate programmer my want to use only CRC verified readings) but
> Marchaudon knows better.
>
> Vasi
>
> On Dec 14, 9:43 pm, mattschinkel <[email protected]> wrote:
>
>> I'm not following this topic much, but I see your talking about CRC.
>> Could it be put into a separate library?
>>
>> Matt.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "jallib" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<jallib%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/jallib?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "jallib" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<jallib%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/jallib?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

<<328.png>>

Reply via email to