Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Installing & Configuring Java for HC11Boot 91.305 home   syllabus html pdf assignment 1 html pdf rev'd short syll. txt lecture 3 notes txt data sheets html uml305dev html pdf parts list pdf assembly html pdf assignment 2a html pdf assignment 2b html pdf assignment 3   main html pdf   java setup html   files zip bootloader html assignment 4 html pdf assignment 5   main html pdf   files zip   reading pdf assignment 6 html pdf invokevirtual pdf assignment 7 html pdf IA-32 manual pdf assignment 8 html pdf assignment 9 pdf review html pdf resources data IKonboard software Installing & Configuring Java for HC11Boot This document explains how to: install Sun's Java Development Kit (JDK) on a Windows PC; install the javax.comm serial communications library and driver; compile the HC11Boot.java test program for communicating with your 68HC11; run the HC11Boot program and have it download a tiny test program onto your 68HC11. There are two sets of instructions: one for installing Sun's JDK 1.1.8 on your own machine, and another for using the Windows 2000 machines in the Olsen 314 lab. At the end of this document, there are notes for using the HC11Boot.java program on non-Windows computers. Your Own PC The following instructions are for those of you who wish to set up your own PC for development. Installing JDK 1.1.8 You will need to download and install Sun's Java Development Kit. I recommend the old 1.1.8 version because it's smaller and faster than the latest versions and it runs perfectly well. So the instructions that follow will assume you're taking my suggestion and using this obsolete, but eminently functional, version of Java. You are of course free to download and install the latest-and-greatest, but then you'll have to adapt the instructions accordingly on your own. First download the 1.1.8 JDK from Sun. You may use their URL http://java.sun.com/products/archive/jdk/1.1.8_010/index.html or you may retrieve a local copy. Run the installer, and the whole system will get installed under C:\JDK1.1.8\. Installing javax.comm javax.comm is the name of the standard libraries created by Sun for interacting with a serial port from the Java language. I have created a tiny zip download that has precisely the three necessary files and an installer batch file for putting them in the right place. Download the javax.comm for JDK118 zip file and extract it into a temporary directory. There will be three files and an installer batch file named install-JDK118.bat. Run the batch file (double-click on it), and the following files will be copied to the following directories: win32com.dll to C:\JDK1.1.8\BIN\ comm.jar to C:\JDK1.1.8\LIB\ javax.comm.properties to C:\JDK1.1.8\LIB\ After the installer runs, check that the three files are indeed in their specified locations. Configuring Paths Now you need to tell your PC where the Java binaries are located (they're in C:\JDK1.1.8\BIN\). Also, you need to create an environment variable named CLASSPATH that tells the Java software about the new comm.jar communications library. The way to do this is to modify the Environment Variables setting. Go to the Control Panels, then open the System icon. From the System Properties window that then opens, click on the Advanced tab. Then, click on the Environment Variables button. The Environment Variables window will show. In the bottom half are the System Variables. There will already be an entry for the PATH. You want to add on to the end of the existing value, so select PATH, click the Edit button, right-arrow to the end, and then add: ;C:\JDK1.1.8\BIN\ Note the initial semicolon. Then you'll want to create a CLASSPATH environment variable. Click the New button, type CLASSPATH into the name field, and set its value to be: .;C:\JDK1.1.8\LIB\COMM.JAR Note the initial period, then a semicolon, followed by the location of the communications .jar file. Now boot up a DOS shell (Start Menu:Run and type cmd or, if, on an older Windows machine, type command). At the shell, type java . If you see a bunch of text starting with usage: java [-options] class etc. then you're all set. Compiling the HC11Boot.java and Serial.java Files OK, you're ready to compile Java code! Create a directory for your work, download the two test files for this exercise (use Assignment 3: Files link on left menu), and put them both into the directory: Serial.java—a small library for opening, reading, and writing to the serial port. HC11Boot.java—a driver program for bootstrap download into the 68HC11E chip's internal RAM. Please note that Java is case-sensitive with respect to filenames, so the files must have the proper capitalization when installed on your disk: Serial.java and HC11Boot.java. Now, from the MS-DOS command shell, change directory (the cd command) to the directory where these two files are located, and compile them together by typing: javac *.java If you didn't get any errors, it worked! You should now have two additional files named Serial.class and HC11Boot.class. If you got an error related to javax.comm, it probably has to do with the CLASSPATH setting. Go back and make sure you did that step properly. Type set at the command shell and it should show you the CLASSPATH value. Running HC11Boot to Discover Serial Ports Now let's run the HC11Boot.java program. Still at the command shell, type: java HC11Boot Again, please note that you must follow the capitalization HC11Boot exactly. When run without arguments, the HC11Boot program displays a list of available serial ports. You should see a result like: Usage: HC11Boot serial-port Available ports are: COM1 COM2 If you get at least one serial port showing up as available, congratulations! You're now ready to talk to your 68HC11; skip to the next step. If you instead got the message “no ports found”, there are a couple of possibilities: There actually aren't any serial ports available on your system—either the low-level comm port drivers are not installed right, or other programs have them open. The javax.comm drivers are not installed properly. To see if you should have available serial ports, please run the standard communications package HyperTerminal (it may already be on your machine; check Start Menu->Accessories->Communications). See if it presents you with any serial ports to connect to. If yes, then it's likely a javax.comm setup problem—skip to the next paragraph. If HyperTerminal did not give you any COM port choices, then you likely have a lower-level serial driver problem. This would be beyond the scope of this document, but resolution generally involves a trip to the Device Manager in Windows' System Control Panel, and in extreme cases, change to your CMOS machine configuration. If you suspect a javax.comm configuration problem, make sure that the win32comm.dll file is properly in the JDK bin directory and that the javax.comm.properties file is in the JDK lib directory. Running HC11Boot to Load a Program on your 68HC11 The function of the HC11Boot program is to install a program into the 68HC11E's 512 bytes of internal memory using the chip's bootstrap download feature. The distribution version of the file installs a three-instruction program that turns on bit 4 of the Port A register. This is represented with the following excerpt from the HC11Boot.java file: buf[i++] = (byte)0x86; // RAM loc 0 -- LDAA with 0x10 buf[i++] = (byte)0x10; // 1 0x10 (bit 4 on) buf[i++] = (byte)0xb7; // 2 -- STAA extended to 0x1000 buf[i++] = (byte)0x10; // 3 0x10 buf[i++] = (byte)0x00; // 4 0x00 (the PORTA reg) buf[i++] = (byte)0x7e; // 5 -- JMP extended to 0x0005 buf[i++] = (byte)0x00; // 6 0x00 buf[i++] = (byte)0x05; // 7 0x05 (loop the JMP!) The three instructions are LDAA 0x10, STAA 0x1000, and JMP 0x0005. These instructions put the number 0x10 into the A register, store this value to the PORTA data register—thereby setting the Port A 4 bit high—and then loop endlessly. Now we are ready to download this program to the 68HC11. OK, you've got a valid serial port, probably COM1 or COM2 since you're on a PC. Plug your assembled 68HC11 system into the serial port using your DB9 cable. Turn the board on. LED8, which should be hooked up to the 6811's TxD, should be off. This indicates that the 6811 is correctly in the bootstrap mode (power on but TxD LED off). Also, the probe LED indicating the state of PA4 should be green, indicating logic low. This is the default power-on state of the PA4 output. Type at the MS-DOS prompt: java HC11Boot COM1 replacing COM1 with whichever serial port you are using, of course. The green SER-IN LED on the UML305DEV board should start flashing. The LED8 HC11 TxD indicator should also flash, as the 6811 replies to the host computer while the bootstrap download is happening. (The TxD isn't hooked back to the PC, so the replies aren't received, but that's OK.) When the flashing is done and the HC11Boot program has finished, the probe LED should turn red, indicating logic high. Then little boot program has run and set PA4 to a one! Also, the LED1 TxD indicator should turn on fully. If all this works, congratulations! Your 68HC11 system is up and running. If you didn't get the PA4 to turn to one, then check all of your wiring and try again. You may need to come to lab where we have more advanced tools for debugging the set-up.       The Windows 2000 Machines in OS314 The following instructions are for those of you who wish to use the Windows 2000 machines in Olsen 314. Using JDK 1.4.0 Sun's Java Development Kit 1.4.0 is already installed on these machines. The whole system is located in C:\forte_jdk\j2sdk1.4.0\. Installing javax.comm javax.comm is the name of the standard libraries created by Sun for interacting with a serial port from the Java language. I have created a tiny zip download that has precisely the three necessary files and an installer batch file for putting them in the right place. Now, someone may have already installed the javax.comm stuff on the machine you're sitting in front of. So before proceeding, check to see if the following files are located in the following directories: win32com.dll goes in c:\forte_jdk\j2sdk1.4.0\jre\bin\ comm.jar goes in c:\forte_jdk\j2sdk1.4.0\lib\ javax.comm.properties goes in c:\forte_jdk\j2sdk1.4.0\jre\lib\ If not, download the javax.comm for JDK140 zip file and extract it into a temporary directory. There will be three files and an installer batch file named install-OS314.bat. Run the batch file (double-click on it), and the aforementioned files will be copied to the aforementioned directories. After the installer runs, check that the three files are indeed in their specified locations. Configuring Paths You need to create an environment variable named CLASSPATH that tells the Java software about the new comm.jar communications library. Start off by booting up the W2000 command shell (choose Start Menu, Run, and type “cmd”. Now enter the following command: SET CLASSPATH=.;C:\FORTE_JDK\J2SDK1.4.0\LIB\COMM.JAR This sets the Java classpath to use first the working directory, but also the serial communications library. Leave the command shell open, because you'll be doing all subsequent work from here as well. Compiling the HC11Boot.java and Serial.java Files OK, you're ready to compile Java code! Create a directory for your work, download the two test files for this exercise (use Assignment 3: Files link on left menu), and put them both into the directory: Serial.java—a small library for opening, reading, and writing to the serial port. HC11Boot.java—a driver program for bootstrap download into the 68HC11E chip's internal RAM. Please note that Java is case-sensitive with respect to filenames, so the files must have the proper capitalization when installed on your disk: Serial.java and HC11Boot.java. Now, from the MS-DOS command shell, change directory (the cd command) to the directory where these two files are located, and compile them together by typing: \forte_jdk\j2sdk1.4.0\bin\javac *.java If you didn't get any errors, it worked! You should now have two additional files named Serial.class and HC11Boot.class. If you got an error related to javax.comm, it probably has to do with the CLASSPATH setting. Go back and make sure you did that step properly. Type set at the command shell and it should show you the CLASSPATH value. Running HC11Boot to Discover Serial Ports Now let's run the HC11Boot.java program. Still at the command shell, type: \forte_jdk\j2sdk1.4.0\jre\bin\java HC11Boot Again, please note that you must follow the capitalization HC11Boot exactly. When run without arguments, the HC11Boot program displays a list of available serial ports. You should see a result like: Usage: HC11Boot serial-port Available ports are: COM1 COM2 If you get at least one serial port showing up as available, congratulations! You're now ready to talk to your 68HC11; skip to the next step. If you instead got the message “no ports found”, there are a couple of possibilities: There actually aren't any serial ports available on your system—either the low-level comm port drivers are not installed right, or other programs have them open. The javax.comm drivers are not installed properly. To see if you should have available serial ports, please run the standard communications package HyperTerminal (it may already be on your machine; check Start Menu->Accessories->Communications). See if it presents you with any serial ports to connect to. If yes, then it's likely a javax.comm setup problem—skip to the next paragraph. If HyperTerminal did not give you any COM port choices, then you likely have a lower-level serial driver problem. This would be beyond the scope of this document, but resolution generally involves a trip to the Device Manager in Windows' System Control Panel, and in extreme cases, change to your CMOS machine configuration. If you suspect a javax.comm configuration problem, make sure that the win32comm.dll file is properly in the JDK bin directory and that the javax.comm.properties file is in the JDK lib directory. Running HC11Boot to Load a Program on your 68HC11 The function of the HC11Boot program is to install a program into the 68HC11E's 512 bytes of internal memory using the chip's bootstrap download feature. The distribution version of the file installs a three-instruction program that turns on bit 4 of the Port A register. This is represented with the following excerpt from the HC11Boot.java file: buf[i++] = (byte)0x86; // RAM loc 0 -- LDAA with 0x10 buf[i++] = (byte)0x10; // 1 0x10 (bit 4 on) buf[i++] = (byte)0xb7; // 2 -- STAA extended to 0x1000 buf[i++] = (byte)0x10; // 3 0x10 buf[i++] = (byte)0x00; // 4 0x00 (the PORTA reg) buf[i++] = (byte)0x7e; // 5 -- JMP extended to 0x0005 buf[i++] = (byte)0x00; // 6 0x00 buf[i++] = (byte)0x05; // 7 0x05 (loop the JMP!) The three instructions are LDAA 0x10, STAA 0x1000, and JMP 0x0005. These instructions put the number 0x10 into the A register, store this value to the PORTA data register—thereby setting the Port A 4 bit high—and then loop endlessly. Now we are ready to download this program to the 68HC11. OK, you've got a valid serial port, probably COM1 or COM2 since you're on a PC. Plug your assembled 68HC11 system into the serial port using your DB9 cable. Turn the board on. LED8, which should be hooked up to the 6811's TxD, should be off. This indicates that the 6811 is correctly in the bootstrap mode (power on but TxD LED off). Also, the probe LED indicating the state of PA4 should be green, indicating logic low. This is the default power-on state of the PA4 output. Type at the MS-DOS prompt: \forte_jdk\j2sdk1.4.0\jre\bin\java HC11Boot COM1 replacing COM1 with whichever serial port you are using, of course. The green SER-IN LED on the UML305DEV board should start flashing. The LED8 HC11 TxD indicator should also flash, as the 6811 replies to the host computer while the bootstrap download is happening. (The TxD isn't hooked back to the PC, so the replies aren't received, but that's OK.) When the flashing is done and the HC11Boot program has finished, the probe LED should turn red, indicating logic high. Then little boot program has run and set PA4 to a one! Also, the LED1 TxD indicator should turn on fully. If all this works, congratulations! Your 68HC11 system is up and running. If you didn't get the PA4 to turn to one, then check all of your wiring and try again. You may need to come to lab where we have more advanced tools for debugging the set-up.       Notes for Non-Windows OSes The only special trick for running on non-Windows OS'es is finding a replacement for the javax.comm libraries. There is an open-source initiative located at http://www.rxtx.org for making replacement javax.comm-compatible drivers for lots of different OS'es. From this site, download, configure, and install the rxtx drivers appropriate for the OS you are running. The latest versions of the rxtx stuff are located a package named gnu.io rather than javax.comm. To compile to this package, in the Serial.java file, comment out the line “import javax.comm.*;” and comment in the line “import gnu.io.*;”. Last modified: Tuesday, 01-Apr-2003 17:38:52 EST by