EasyManuals Logo

Chino KP3000 User Manual

Default Icon
88 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #25 background imageLoading...
Page #25 background image
- 22 -
Reference: CRC-16 calculation program
/***** CRC-16 calculation program (C language) *****/
#include <stdio.h>
#include <conio.h>
void main(void)
{
/*** Internal change declaration ***/
unsigned int iLoopCnt; /* Loop counter */
unsigned short usData; /* Input data */
unsigned short usCrcData; /* CRC-16 data */
unsigned short usErrChkData; /* Error check data */
int iDummy; /* Dummy variable */
/* Initialize the output result of CRC-16 data */
usCrcData = 0xffff;
printf“Enter hexadecimal data.(End using [q]) >\n”);;
while( scanf(“%x”,&usData) != 0 )
{
/* Get the exclusion of CRC output result and the data that is input */
usCrcData = usData ^ usCrcData;
/*** Do the CRC calculation ***/
/* Repeat till shifting up to 8 bits is done */
for( iLoopCnt = 0 ; iLoopCnt < 8 ; iLoopCnt++ )
{
/* Check the existence of carry */
if( usCrcData & 0x0001 )
{
/* When carry occurs */
/* Shift CRC output result 1 bit to the right */
usCrcData = usCrcData >> 1;
/* Get the exclusion with A001H */
usCrcData = usCrcData ^ 0xa001;
}
else
/* When carry does not occur */
/* Shift CRC output result 1 bit to the right */
usCrcData = usCrcData >> 1;
} /* for */
} /* while */
printf( “CRC-16 data is %xH..\n”, usCrcData );
/* Create error check data */
usErrChkData = ( usCrcData >> 8) | ( usCrcData << 8 );
printf( “Data for error check is %xH.”, usErrChkData );
iDummy = getch();
}

Table of Contents

Other manuals for Chino KP3000

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Chino KP3000 and is the answer not in the manual?

Chino KP3000 Specifications

General IconGeneral
BrandChino
ModelKP3000
CategoryController
LanguageEnglish

Related product manuals