Department of Electrical and Computer Engineering Facebook page


  • DEPARTMENT
    • Overview
    • Computing
    • Facilities
    • Organizations
    • Educational Objectives
    • Student Outcomes
    • Scholarship Awards
    • Employment
    • Advisory Committee
    • Contact
  • ACADEMICS
    • Undergraduate
      • Computer Eng.
      • Electrical Eng.
      • Ambassadors
    • Graduate
      • Information for Prospective Students
      • ECE Graduate Handbook
      • Graduate Forms
      • Ph.D. Qualifying Exam
      • Distance Education
      • Frequently Asked Questions (FAQ)
    • Courses
    • Student Survival kit
    • Distance Learning
  • PEOPLE
    • Faculty
    • Staff
  • PROSPECTIVE STUDENTS
    • Overview
    • FAQ
    • Considering ECE
    • Scholarships
    • PC Requirements
    • Office of Admissions
  • RESEARCH
    • Overview
    • Signal Processing & Communications
    • Digital Systems & Microelectronics
    • Power & High Voltage
    • Research Centers
      • Emerging Materials Research Laboratory
      • High Voltage Laboratory
      • Robotics
    • HPCC
  • ALUMNI
ECE3724 Microprocessors/lab page/old - Ece
Personal tools
  • Log in
Views
  • Page
  • Discussion
  • View source
  • History

ECE3724 Microprocessors/lab page/old

From Ece

< ECE3724 Microprocessors | lab page
Jump to: navigation, search

Contents

  • 1 Jolt Bootloader
    • 1.1 Jolt Bootloader v1.2 for Linux Setup
  • 2 MCC18 Compiler Oddities
    • 2.1 Mixed 8-bit/16-bit calculations

Jolt Bootloader

Jolt is the excellent Java-based serial port bootloader for the Microchip PIC18 family of microcontrollers from Martin Dubuc. If you choose to use Windows, Martin Dubuc has provided a C-language Windows version called Colt. Colt may be the better choice in that it has many fewer installation headaches.

However, if you have reached a higher state of enlightenment and run on Linux, Jolt is your only choice for PIC18 serial port bootloading. Unfortunately, time and diverging software revisions have conspired against Jolt. Jolt uses Sun Microsystems' javax.comm Communications API which was heavily altered in mid-2006 such that the third party HW-access libraries like RXTX will no longer work. If you need to use Jolt v1.2 on Linux, then you must follow the following instructions exactly:

(The following instruction should also work for Jolt for Windows setups provided you make the appropriate changes.)

Jolt Bootloader v1.2 for Linux Setup

  1. Download the Java JDK v.1.5.0 release 12 from Sun's website. (You MUST get this version of the SDK/JRE. Jolt requires JRE 1.5 or later to work, but the older RXTX libraries we'll use will not compile properly with JDK 1.6 and later. So, Java 1.5 it will be!!!!)
  2. Install this JDK (with JRE) on your machine. (I recommend installing the jdk1.5.0_12 folder into /usr/lib.)
  3. In your account profile (.bashrc if you use that shell), be sure to create the environment variable JAVA_HOME which equals the path to the JDK, /usr/lib/jdk1.5.0_12, in our example.
  4. Download the GENERIC Java Communications API v.2.0.3 from Sun's website. A local copy has been placed here since Sun is famous for making older versions inaccesible over time.
  5. Get the file comm.jar from the archive above, and place it in $JAVA_HOME/jre/lib/ext
  6. Download the RXTX v.2.0.7pre2 source code tar archive from the RXTX library website. (A local copy can be downloaded from here.)
    • You MUST get the version 2.0-7pre2. The later versions of RXTX (2.1 and higher) will NOT work with Jolt v1.2.
  7. Explode the RXTX source code archive with tar -xvf rxtx-2.0-7pre2.tar.gz
  8. cd into the code tree and run ./configure. If successful, run make. Do whatever it takes to get a clean configure and build. Follow the prompts given by the scripts.
    • You may need to get or update some basic Linux apps, libraries, or header files to make ./configure happy. This is imperative since ./configure is "making" the Makefile.
    • If you don't have the right JDK installed, or the JDK is not "visible" to the configure script, it will either build a unusable target or die a violent, ugly death. Be careful here!!!!
  9. If all went well, you should now have a RXTXcomm.jar file in RXTX directory, and there should be a couple of machine libraries librxtxSerial-2.0.7pre2.so and librxtxParallel-2.0.7pre2.so in the RXTX subfolder
    • i686-linux-gnu/.libs for i386 computer, or
    • amd64-linux-gnu/.libs for AMD x64 computers.
  10. Copy the created RXTXcomm.jar to $JAVA_HOME/jre/lib/ext folder
  11. Copy the machine library files librxtxSerial-2.0.7pre2.so and librxtxParallel-2.0.7pre2.so to the folder $JAVA_HOME/jre/lib/i386 or $JAVA_HOME/jre/lib/amd64 folder, as appropriate for your computer.
  12. Now, cd into either the $JAVA_HOME/jre/lib/i386 or $JAVA_HOME/jre/lib/amd64 as appropriate and create symbolic links, e.g
    • ln -s librxtxSerial-2.0.7pre2.so librxtxSerial.so
    • ln -s librxtxParallel-2.0.7pre2.so librxtxParallel.so
  13. Next, cd into the $JAVA_HOME/jre/lib folder. Create a file named javax.comm.properties
  14. Edit the file javax.comm.properties to contain the following line:
    • Driver=gnu.io.RXTXCommDriver
      • (Some people report that a blank line should be included after the Driver=... line above. My machine appears to work fine without it.)
  15. Finally, you need to create the environment variable CLASSPATH in your account profile. Set CLASSPATH equal to the paths to the library folders, e.g. $JAVA_HOME/jre/lib and $JAVA_HOME/jre/lib/ext. I use the following in my .bashrc file:
    • export CLASSPATH="$JRE_HOME/lib/ext:$JRE_HOME/lib/:."

Now, the Jolt v.1.2 bootlaoader should work properly by running

  • java -cp Bootloader.jar Bootloader

at the command line. Good luck!

MCC18 Compiler Oddities

There are some 'gotchas' associated with the MCC18 compiler that you should be aware of, see the topics below.

Mixed 8-bit/16-bit calculations

The default behavior for the MCC18 compiler for mixed 8-bit/16-bit calculations is strange. This can affect some lab exercises, particularly the CCPR1 calculation for servo control in Lab #11. In the following code snippet

 unsigned char x,y;  //8-bit values
 unsigned int  k,j;  //16-bit values
 j = k + x * y;  //mixed 8-bit, 16-bit calculation

note that k, j are 16-bits, and x, y are 8-bits. If k = 100, x = 2, y = 128, then most compilers produce the result:

  j = 100 + 2*128 = 100 + 256 = 356

In this case, the multiplication of 2*128 is treated as a 16-bit computation because the result value j is a 16-bit value, so the product 2*128 is done with 16-bits. However, the default behavior for the MCC18 compiler is to perform an operation using the size of the largest operand. In this case, since both x and y are 8-bits, the multiplication of 2*128 is done with 8-bit precision, and the result of 256 is > 255, resulting in a wrapped value of 0. The calculation returns:

  j = 100 + 2*128 = 100 + 0 = 100, which is the wrong answer!!

To defeat this behavior, you have to explicitly cast at least one of the 8-bit values as a 16-bit value:

  j = k + ((unsigned int) x) * y;

in the MCC18 compiler. There is also a compiler flag that will do this - use "-Oi+" to force integer promotions. Command lines options tend to change over time, so read the MCC18 help file to ensure that this command line option is still valid (look for a discussion on integer promotion behavior).

Retrieved from "http://www.ece.msstate.edu/wiki/index.php/ECE3724_Microprocessors/lab_page/old"
Navigation
  • Main Page
  • Community portal
  • Current events
  • Recent changes
  • Random page
  • Help
SEARCH
TOOLBOX
LANGUAGES
 
Toolbox
  • What links here
  • Related changes
  • Upload file
  • Special pages
  • Printable version
  • Permanent link
Powered by MediaWiki
  • This page was last modified on 23 May 2008, at 16:19.
  • This page has been accessed 277 times.
  • Privacy policy
  • About Ece
  • Disclaimers

Mississippi State University Home| PO Box 9571, Mississippi State, MS 39762 | Main Office: 1.662.325.3912

Bagley College of Engineering | Mississippi State University| Legal| Webmaster| Intranet

Page modified: Tue, 23 Sep 2008 15:18:39 CDT