// HC11Boot.java: bootstrap program for loading code into HC11 // Fred Martin / UML CS / last modified Mon Sep 29 08:35:40 2003 // // put the bytes you want installed into HC11 internal RAM // into "buf" object beginning at buf[0]. class HC11Boot { private static Serial s; public static void main(String[] argv) { setup(argv); // select serial port and init Serial object System.out.println("Using serial port " + s.getPortName()); // make 512 byte buffer and fill with zeroes byte[] buf= new byte[512]; int i; for (i=0; i<512; i++) buf[i] = 0; // this 3-instruction program will turn on bit 4 of PORTA (PA4) // and then loop endlessly i=0; 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!) System.out.println("Serial port is open. Turn on HC11 and press to continue..."); try { System.in.read(); } catch (Exception e) { e.printStackTrace(); } System.out.println("Writing to serial line..."); try { s.put(0xff); // send baud rate detect byte s.put(buf); // dump 512 bytes to serial port } catch (Exception e) { e.printStackTrace(); } s.flush(); // make sure all chars get out before exiting System.out.println("done."); } private static void setup(String[] args) { if (args.length == 0) { System.out.println("Usage: HC11Boot serial-port"); s = new Serial(); String[] ports=s.portsAvailable(); int nPorts= ports.length; System.out.println("Available ports are:"); for (int i=0; i< nPorts; i++) { System.out.println(" " + ports[i] + " "); } System.out.println(); System.exit(0); } s = new Serial(args[0]); } }