Allen-Bradley 1784-KTX Reference Manual page 112

Table of Contents

Advertisement

case 'a':
case 'A':
/* Get the address of the board */
sscanf(&argv[i][2], "%x", &address);
if (!(address & 0xff00)) address <<= 8;
break;
default:
usage(argv);
exit(2);
}
}
/* Check to see if all required inputs have been issued on the command line */
if ((strlen(loadfile_name) == 0) || (address == 0)) {
usage(argv);
exit(2);
}
/* Setup pointer to point to base of dual port */
base = (char far *) MK_FP(address,0x0000);
/* Reset the KTX (stop it from running) */
base[KTX_RESET] = 1;
/* open the clrram.bin file, to download it to dual port to clear the
ram on the KTX */
if ((ifile = open("CLRRAM.BIN", O_BINARY | O_RDONLY)) == –1) {
printf("Error opening CLRRAM.BIN.\n");
exit(1);
}
/* Read the bytes from the file directly into dual port ram */
length = read(ifile, base, 0x800);
/* Close the file */
close(ifile);
/* Start the KTX running to execute the CLRRAM.BIN to clear ram to zeros */
base[KTX_RELEASE] = 1;
/* Wait for clrram.bin to finish or user hits keyboard */
while(base[length – 2]) if (kbhit()) exit(1);
/* Stop the KTX */
base[KTX_RESET] = 1;
/* If user did not request load directly to dual port, then first load
the loadpcl.bin program (bootstrap program) */
if (file_into_dp == FALSE) {
if ((ifile = open("LOADPCL.BIN", O_BINARY | O_RDONLY)) == –1 ) {
printf("Error opening LOADPCL.BIN\n");
exit(1);
}
/* Read up to 0x800 bytes from file into start of dual port */
read(ifile, base, 0x800);
close(ifile);
}
if ((loadfile = open(loadfile_name, O_BINARY | O_RDONLY)) == –1) {
printf("Could not open file %s.\nExitting...\n",loadfile_name);
exit(1);
}
Appendix B
Programming Examples
/* If address given as a
/* byte, shift it to a word */
*/
B-33

Advertisement

Table of Contents
loading

This manual is also suitable for:

1784-ktxd1784-kts

Table of Contents