Hi everyone,
Does anyone know how to concatenate a binary number to another binary number? I would like to know this for crc calculation.
Manny thanks,
Ray
Can you actually concatenate binary, I thought it was only text or strings??
Bob
I agree with Bob, what exactly are you trying to do Ray? Maybe you want to And or Or or Xor.
John
I am trying to write a CRC-7 routine for writing to a SD-card. I read online that the message as a whole forms a big binary number on which you perform Xor.
Is the message a row of ASCII ones and zeros and you need to put that into a dword?
John
The CRC values are only really required with certain commands sent to the SD card and the values required can be pre-calculated as constants, then used in a simple comparison.
I did a bit of research and I have just created the procedure below that "should" perform a CRC7 calculation. It is untested, but should give you some pointers for the code:
'
' Create a global variable for the CRC7_Update procedure to update
'
Dim Global_bCRC As Byte ' Holds the CRC value that is updated with bytes read
'-------------------------------------------------------------------------------
' Update a CRC value
' Input : Global variable Global_bCRC holds the CRC value to update
' : pData holds the data to add to the Global_bCRC variable
' Output : Global Variable Global_bCRC holds the updated CRC value
' Notes : None
'
Proc CRC7_Update(pData As Byte)
Dim bTemp As Byte
pData = pData ^ Global_bCRC
Global_bCRC = pData >> 4
bTemp = (Global_bCRC ^ (Global_bCRC >> 3))
pData = pData ^ bTemp
bTemp = pData << 1
Global_bCRC = bTemp ^ (pData << 4)
EndProc
'---------------------------------------------------------------------------------
Main:
Global_bCRC = 0
CRC7_Update(10)
CRC7_Update(20)
The global variable "Global_bCRC" will be updated by the CRC7_Update procedure with the data sent to it.
If memory serves, SD cards also use a CRC16 calculation for some commands, but, again, these can be pre-calculated because the values returned from the commands are known.
Thanks very much for the reply, I think i've got enough to go on. Did a bit more reading and indeed they can be pre-calculculated. Still would like to be familiar with the way to calculate them, so i'm going to play around a bit with the example of Top204.