ASDA-M Chapter 9 Communication
Revision December, 2014
9-17
Example of CRC program:
Produce CRC in C language. This function needs two parameters:
unsigned char* data;
unsigned char length
This function returns CRC of unsigned integer.
unsigned int crc_chk(unsigned char* data, unsigned char length) {
int j;
unsigned int reg_crc=0xFFFF;
while( length-- ) {
reg_crc^= *data++;
for (j=0; j<8; j++ ) {
if( reg_crc & 0x01 ) { /*LSB(bit 0 ) = 1 */
reg_crc = (reg_crc >> 1)^0xA001;
} else {
reg_crc = (reg_crc>>1);
}
}
}
return reg_crc;
}
Example of personal computer procedure:
#include<stdio.h>
#include<dos.h>
#include<conio.h>
#include<process.h>
#define PORT 0x03F8 /* the address of COM 1 */
#define THR 0x0000
#define RDR 0x0000
#define BRDL 0x0000
#define IER 0x0001
#define BRDH 0x0001
#define LCR 0x0003
#define MCR 0x0004
#define LSR 0x0005
#define MSR 0x0006
unsigned char rdat[60];
/* read 2 data from address 0200H of ASD with address 1 */
unsigned char tdat[60]={‘:’,’0’,’1’,’0’,’3’,’0’,’2’,’0’,’0’,’0’,’0’,’0’,’2’,’F’,’8’,’\r’,’\n’};
void main() {
int I;
outportb(PORT+MCR,0x08);
/* interrupt enable */
outportb(PORT+IER,0x01); /*
interrupt as data in */
outportb(PORT+LCR,( inportb(PORT+LCR) | 0x80 ) );
/* the BRDL/BRDH can be access as LCR.b7 == 1 */
outportb(PORT+BRDL,12);
outportb(PORT+BRDH,0x00);
outportb(PORT+LCR,0x06);
/* set prorocol
<7,E,1>
=
1AH,
<7,O,1>
=
0AH
<8,N,2>
=
07H
<8,E,1>
=
1BH
Содержание ASD-M-0721 Series
Страница 20: ...ASDA M Chapter 1 Inspection and Model Explanation Revision December 2014 1 7 ASDA M Series Servo Drive top view...
Страница 36: ...ASDA M Chapter 2 Installation Revision December 2014 2 15 Delta Part Number BR1K5W005 3kW 10...
Страница 37: ...Chapter 2 Installation ASDA M 2 16 Revision December 2014 This page is intentionally left blank...
Страница 161: ...Chapter 6 Control Mode of Operation ASDA M 6 36 Revision December 2014 Frequency Domain...
Страница 231: ...Chapter 7 Motion Control ASDA M 7 44 Revision December 2014 This page is intentionally left blank...
Страница 631: ...ASDA M Appendix A Accessories A 10 Revision December 2014 RS 485 Connector Delta Part Number ASD CNIE0B06...
Страница 645: ...Appendix B Maintenance and Inspection ASDA M B 4 Revision December 2014 This page is intentionally left blank...