CPU_3A2 - F.A.Q. PMB Home

I would like to thank Ryan Salsbury for contributing Technical questions. The code is written for the assembler that comes with the Imagecraft compiler.

If anyone would like to see a specific question covered, please let me know and I will do my best.

Contents:

  1. Do I need the development board?

  2. I've received the package, what now?
  3. I'm a beginner, Where should I start?
  4. What Motorola documentation should I have?
  5. Which programming tools should I use?
  6. What do I need to supply?
  7. Can the Flash memory be used for data logging?
  8. Can the CPU_3A2 be supplied with larger Flash memory?
  9. Does the Flash memory wear-out?
  10. What about the different Flash memory chips?
  11. How do I operate the HC11Boot loader program?
  12. How do I fix HC11Boot error message problems?
  13. Can HC11Boot still support the CPU_1A board?
  14. How do I fix a communication problem?
  15. Which terminal program to use?

  1. Speeding up bootstrap downloads.

  2. DOS copy command problems.
  3. Setting the baud rate in DOS.
  4. Using flash for startup code.
  5. Bank selection changes unexpectedly.
  6. Disabling or moving the eeprom bank.
  7. Configuring the chip selects.
  8. Writing a byte to eeprom.
  9. Writing to flash.
  10. How to make a program autostart from Flash memory
  11. Communications speeds.
  12. Can I connect a modem?

  1. Reloading Buffalo into Flash memory.

  2.  

 

Basic Level

Q1. Do I need a development board?

    No, the CPU_3A2 will operate alone; but we do strongly recommend it if you are starting out.

    The CPU_3A2 has 52 pins of connections arranged as two 26-way (2x13) headers, on the bottom of the board. Without a circuit board to connect with, it can be tricky to wire to. Soldering directly to teh CPU_3A2 is not recommended as it can be damaged.

    The development board provides a socket mounting for the CPU_3A2 and an assortment of connections for power, RS-232 and much of the direct input/output.

    If you do make your own board, we recommend that you socket the CPU_3A2. This allows for full testing before adding the CPU_3A2 itself.

Q2. I've received the package, What now?

  • Make sure you have a suitable 12V power supply or plug-pack. The center terminal must be +ve.

  • You will need an available serial port on your PC, and a straight-throught lead to connect to the 9-pin female D-connector on the development board.

  • The CPU_3A2 modules are supplied with Buffalo already loaded into flash memory and tested. To use Buffalo you will need a communications or terminal program running on your PC. HyperTerminal comes with Windows but can cause a few problems. Make sure that you quit and restart HyperTerminal each time you change settings or suspect a problem.

  • With the communications program set to 19200 baud, no parity, 1 stop bit, 8 data bits (19200,n,1,8) and connected to the CPU_3A2 you are ready to go. Apply power to the CPU_3A2 module or press the reset button. The Buffalo greeting should appear on your screen. Press enter and a prompt will appear. Press enter again and a list of command will appear.

  • Now you need to read through the files on the CD or if you don't have a CD contact PMB Electronics for support.

  • The Buffalo monitor is already installed on the CPU module. DO NOT load any of the "erase" hex files. They will wipe out Buffalo. It can be reloaded, but you probably don't want to be doing that as a first step.

Q3. I'm a beginner, Where should I start?

    With the CPU and development board you get a CD with some notes, data and basic tools.

    The tools I recommend starting with are the MiniIde assembler and the HC11boot loader utility. Once MiniIde is installed, go to options and set the assembler to asm11.exe; and check the box for compatibility. This ensures that it can handle the source file syntax and will produce valid output code.

    The HC11boot utility allows you to load the output files from MiniIde into the CPU module. Note that MiniIde produces *.S19 output files. Just set *.S19 in the search criteria in HC11boot.

    HC11boot includes a few utilities which are also included in the "code examples cpu_3a" directory of the CD. These are a good starting point because they show how to configure the CPU module and provide a framework to use to create your own programs.

    NOTE: In the examples given comment out the top 2 lines:

      CPU "G:\USER0\CROSS-32 4.0\68HC11.TBL"
      HOF "MOT8"

    Just put a semi-collon in front of each line. (these are left over from my Cross-32 assembler)

    The best idea would be to start off reading switch inputs, flashing a few LEDs and timing sequences of flashes and beeps. Once you have this operational, you will have a good working knowledge of the system ie. how to create, load and run a program. This is half the battle.

    The next step would be to connect different input/output devices and make them operational. This could include a temperature sensor and a display.

Q4. What HC11 documentation should I have?

Q5. Which programming tools should I use?

    For those of you using Windows, I would recommend MiniIDE as an editor and assembler, and my HC11boot to download the *.hex files to the CPU_1A1.

    For the beginner, I would recommend the Windows programs because it simplifies keeping track of files and allows both programs to be open at the same time.

    These programs are supplied on CD with you first CPU_3A2 purchase.

Q6. What do I need to supply?

    A straight through male-female 9-pin RS-232 cable (the development board has a female 9-pin D connector).

    A 12V DC 150mA (minimum) plug pack. The development board has a 2.1mm DC power socket with center pin +ve.

    We can supply suitable plug-packs to New Zealand customers. We don't supply plug-packs overseas because of the weight and differences between countries.

Q7. Can the Flash memory be used for data logging?

    Yes, BUT, you cannot execute code from flash and write to it at the same time. It gets a bit more complex. You can copy a flash write routine to RAM, then run code from RAM while the flash is written.

Q8. Can the CPU_3A2 be supplied with larger Flash memory?

    Not on the CPU_3A2 module. It comes with a 4Mbit flash chip (512K bytes). You could add more memory off the board if required, but there are many ways to do this and each application should be considered seperately.

Q9. Does the Flash memory wear-out?

    Yes, the flash does have a maximum number of write/erase cycles. Typically 100,000 at worst-case conditions (max temperature/voltage). Normal use would greatly extend this number. I haven't had one fail or had a failure reported yet.

Q10. What about the different Flash memory chips?

    There are a number of manufacturers of flash memory and many different variations. We currently use an ST brand chip. This is compatible with the AMD chips.

    Availability of flash memory has caused us problems in the past. We started off using AMD flash (AM29F010). When this was not available we were forced to use Atmel flash (AT29C010). Unfortunately the AMD and Atmel use different programming sequences and have deferent internal sector structures. We have also used an Atmel equivalent chip made by SST (ST29EE010).

    All CPU_3A2 modules sold use the ST or AMD compatible chips as these are easier to work with than the Atmel and SST flash. AMD flash can be written one byte at a time in any order with any delay between bytes. The Atmel and SST flash must be written in complete 128 byte sectors with no delay between bytes.

    The Atmel and SST flash may be better suited to data logging than the AMD flash because of the smaller sector size (128 byte vs 16K byte) and simplified write and rewrite.

Q11. How do I operate the HC11Boot loader program?

    HC11Boot allows you to send HEX files to the CPU which can be written to RAM, EEPROM or Flash memory, it depends on the target addresses when you assemble or compile your program.

    Before you "send" a hex file you must press the reset button and "initalise" the CPU. This makes it ready to receive the hex file. Note: the two jumpers (LK1 and LK2) must be ON for this to work.

    When you click on initalise the progress bar moves to the right. On completion the buzzer will activate if you are using the development board (port-D4 goes high). If it does not, you most likely have a communications problem. Check the cables and com port settings see Q12 below.

    Once initalised, you can select a hex file and click "send". The status bar should again move. If it does not, the initalise stage probably didn't complete correctly, look for a comms problem.

    Using the Development Board with Buffalo:

    When first powered on or reset, the TXD led pulses as the Buffalo greeting is sent out, even if the PC is not connected.
    If you hold the reset button down, there is a dim glow from the TXD led.

    Using the Development Board with HC11Boot:
    When first powered on the TXD led comes on.
    When you click initalise, the TXD and RXD leds flicker as the status bar moves.
    On completion, both leds go off and the buzzer comes on.
    When you "send" a hex file, both leds flicker as the file goes through.
    If you hold the reset button down, there is a dim glow from the TXD led.

    Notes:

  • If the CPU is not initalised, when you click on "send", HC11Boot will lock-up. This is because it is waiting for the CPU to echo the data sent to it and it's not going to.
  • The TXD led indicates data going from the CPU to the PC, the RXD led indicates data going from the PC to the CPU. These are very useful when you have a communications problem.
  • Stay clear of any hex file with "erase" in the file name until it's all up and running.
  • Start with the "dump" hex files. These are safe because they only load into RAM and provide an output via the serial port.
  • Caution: HC11Boot can corrupt the Buffalo monitor by over-writing it in Flash memory. Your new program does not replace Buffalo, you get 2 files merged into the same space. The Flash memory must be erased before it can be reloaded with anything; unless you are deliberately writing to another area of Flash memory. You can have more than one program stored in Flash memory at a time (in different areas).
  • HC11Boot has a settings page where you set the communications parameters. Normally, CPU_3A*, 16MHz crystal, 2400 baud for Bootload and 19200 for Load. Make sure you select a valid com port, usually 1 or 2.
  • The "Verify" button is used to verify and execute a loaded program. Verify is not needed when you are loading programs that are executed by some other trigger; like Buffalo, which is executed when the jumpers are removed and the reset button pressed. Verify is required to execute utilities like "dump" and "erase".
  • If you are loading to RAM only, you can check the box above "autosend". This will allow much faster loading by not requiring an echo from the CPU. The echo of each character sent is still there, but it is ignored.
  • The "autosend" button does the same as "initalise, then send, the verify" all with one click. It's usefull when developing code and repeatedly loading into RAM.

Q12. How do I fix HC11Boot error mesage problems?

    The most common problem seems to be an error 383.

    Run HC11boot and select Options / Settings from the top pull-down menu.

    Make sure you have these settings:

    • CPU = CPU_3A*
    • Crystal = 16.000
    • BootLoad = 2400
    • Load = 19200
    • Port = "whichever port you have it connecte to"
    • Echo = on
    • Connection Preferences = 8, None, 1
    • Flow Control = None

    The current HC11boot settings are stored in the registry.
    Experienced users can delete the current settings using Regedit at:

      HKEY_CURRENT_USER/Software/VB and VBA Program Settings/HC11boot
    It's best not to run Regedit unless you know what you are doing, It can do lots of damage.

Q13. Can HC11Boot still support the CPU_1A board?

    Yes.
    Download this zip file and extract the contents to the HC11Boot V1.3 program directory (folder).
    This will provide the bootstrap loader, Buffalo and the erase and dump utilities for the CPU-1A.

    Run HC11boot and select Options / Settings from the top pull-down menu.
    Make sure you have these settings:

    • CPU = CPU_1A*
    • Crystal = 8.000
    • BootLoad = 1200
    • Load = 9600
    • Port = "whichever port you have it connecte to"
    • Echo = on
    • Connection Preferences = 8, None, 1
    • Flow Control = None

    Change the settings back to run with the CPU_3A2 board again.

Q14. How do I fix a communications problem?

    Unfortunately, this is the most likely problem to occur. It means that the CPU module is not communicating correctly with the PC.

    Each CPU module is supplied with Buffalo already installed. With Terra-Term or a similar comms terminal program set to 19200 baus, 8-bit, 1-stop, no-parity, connect and power up. When you press the reset button on the CPU module you should get the Buffalo greeting on the screen. If you are using the development board, the

    Try these steps:

  • See Q15 below regarding terminal programs.
  • Check you are plugged into the correct comms port on the PC.
  • There should be nothing else sharing the port resources; interrupts etc.
  • Make sure you have a suitable DC power supply for the CPU module or development board.
  • Check the port settings, baud rate should normally be 19200 baud 8-bit, 1-stop, no-parity.
  • Check that you have a straight-through (one to one) serial cable.
  • Close all other programs when running under Windows.
  •  

Q15. Which terminal communication program to use?

    In the past we have recommended HyperTerminal because it comes with Windows. Unfortunately, HyperTerminal is rubbish and causes far more trouble than it's worth. On some systems it does causecommunications problems. Please do not use HyperTerminal.

    We now recommend Terra-Term-Pro Version 2.3.

    Terra-Term works well. So far it's been quick and reliable.

    If it's not on the CPU_3A2 CD, a Google search is probably the best way to find the latest version or a good download site.

    Problems with HyperTerminal:

  • Whenever changing settings within HyperTerminal, save the new settings and restart HyperTerminal. Often the new settings don't take effect immediately.
  • HyperTerminal does strange things at times. If you are having communications problems after using HyperTerminal you will probably have to restart your PC. This seems excessive but it's often the only thing that works and it's best to be safe.
     

More Technical

Q1. Can I download the bootstrap code faster than 2400 baud?

    Yes, if you're using an hc11f1. If you change the first byte of your file to 0xF0 instead of 0xFF the f1 will configure itself for 19200 baud.

Q2. I'm downloading code using the DOS copy command but it's not working.

    Make sure you use the /B flag to tell dos the file is a binary file, ie. "copy /B program.hex OM1" Otherwise the copy program will stop sending when it hits a 0x1a byte (Ctrl-Z).

    Under linux (and probably other unixes) the serial port is set to translate LF -> CRLF. The command to enable raw mode is "stty raw < /dev/ttyS0" depending on your serial device.

Q3. How do I set the baud rate in DOS?

    Use the MODE command. Example: mode COM1:1200,n,8,1

Q4. I'm not using internal eeprom for reset vectors, why won't the cpu fetch them from flash?

    The bank-select latch is resets to bank 00 of RAM and Flash whenever the CPU_3A2 is reset. You can relocate the eeprom in memory and put your startup code in flash memory in bank 00.

    See the next question about bank selection.

Q5. Why does the bank selection change unexpectedly?

    The bank-select latch is a write only latch that is enabled by chip select CSIO1 directly from the CPU.

    CSIO1 decodes to all addresses from $1060 to $17FF. Writing to any one of these addresses will load the bank select latch with the data byte written.

    Reading from any of the bank select addresses changes the bank select latch data to FF which forces RAM and flash to the top banks. This is an unexpected bug in the design which will be corrected with the next version.

    It's not a problem so long as you never read from addresses $1060 to $17FF.

    To be safe, I recommend using the top RAM and flash banks as your normal operating areas. The initalisation code provided does this.

Q6. How do I disable or move the internal eeprom bank?

    The CONFIG byte which sets the eeprom status is very hard to modify. It consists of a normal ram register and an underlying eeprom byte. In special test mode and bootstrap mode the register is initialized to place eeprom at 0xfe00 - 0xffff. In single chip and expanded modes the register is loaded from the eeprom byte.

    Here's how I relocate the eeprom to 0x0e00 - 0x0fff:

    In the bootstrap code I program the eeprom byte using the standard eeprom erase and program routines given in the Motorola data sheets. This takes care of expanded mode operation. After I program the eeprom byte I jump to special test mode and set the config register directly. Here's how to go to special test mode:

    Use the HPRIO register to switch to special test mode and program the static latches directly.

        /* go to special test mode */
        HPRIO = 0x66;
        /* move the eeprom to 0x0e00 - 0x0fff */
        CONFIG = 0x0F;
        /* switch to expanded mode */
        HPRIO = 0x26;

Q7. How do I configure the chip selects to work?

    Here's the code:

        ; setup chip selects
        ldd #0x0500
        staa 0x105d ; CSCTL = 0x05
        stab 0x105e ; CSGADR = 0
        stab 0x1002 ; PORTG = 0
        stab 0x1035 ; BPROT = 0
       
        ldd #0x0103
        staa 0x105f ; CSGSIZ = 0x01
        stab 0x1003 ; DDRG = 0x03

    This puts the ram at 0x0000 - 0x7fff and the flash at 0x8000 - 0xfff.

    The HC11 internal registers, ram and eeprom override external memory.

Q8. How do I write a byte to the on-chip eeprom?

    Assume the address of the byte is in X and the data is in A.
    For the config eeprom byte use the address of the config register 0x103f

        delay10ms::
        ldy #2857
        dly_loop:
        dey
        bne dly_loop
        rts
       
        program_eeprom::
        ; erase byte
        ldab #0x16
        stab 0x103b ; PPROG = 0x16
        staa 0,x
        ldab #0x17
        stab 0x103b ; PPROG = 0x17
        jsr delay10ms ; wait 10ms
        clr 0x103b ; PPROG = 0
       
        ; program byte
        ldab #0x02
        stab 0x103b ; PPROG = 0x02
        staa 0,x
        ldab #0x03
        stab 0x103b ; PPROG = 0x03
        jsr delay10ms ; wait 10ms
        clr 0x103b ; PPROG = 0
        rts

Q9. How do I erase and program the flash?

    The following code assumes you have your flash from 0x8000 - 0xffff. Other banks can be accessed by twiddling the bank select latch. Note: the address and data pins are mapped strangely, see the article on the pmb web site.

        ; Wait for the flash to finish a sector erase or
        ; byte program operation. This cryptic code simply
        ; waits for pin Q6 to stop toggling (Q2 on the hc11).
        poll_flash::
        ldy #0x8000
        brclr 0,y,#2,pf2
        pf1:
        brset 0,y,#2,pf3
        pf2:
        brset 0,y,#2,pf1
        pf3:
        rts
       
        ; Erase flash from 0x8000 - 0xffff
        erase_flash::
        ldd #0x55AA
        staa 0xD5AA
        stab 0xAA55
       
        ldaa #0x01
        staa 0xD5AA
       
        ldd #0x55AA
        staa 0xD5AA
        stab 0xAA55
       
        ldaa #0x0C
        staa 0x8000 ; any address in bank 0
        staa 0xC000 ; any address in bank 1
        jsr poll_flash
        rts
       
        ; Assumes data byte is in A, address in X
        program_flash::
        ldab #0x55
        stab 0xD5AA
        ldab #0xAA
        stab 0xAA55
        ldab #0x05
        stab 0xD5AA
        staa 0,x
        jsr poll_flash
        rts

Q10. How to make a program autostart from Flash memory?

    First you have to design your program to run from Flash memory. This involves setting it up to assemble so that it exists starting at $8000 (use the ORG directive).

    Your program must also look after the Start-Up of the CPU and memory bank management. This sounds complicated but it's not really. The easiest way is to boot from EEPROM.

    Look at the sample code "example_3.asm" for a working example. Simply replace the application code section with your own code. (syntax may require adjustment depending on the assembler being used).

    Load the "erase.hex" utility to erase Flash and EEPROM memory, then load your own application (was example_3.asm)

    I recommend using the HC11Boot loader program.

    "example_3.asm" is available for download

Q11. What are the communications speeds?

    The boot loader will initally load the CPU at 2400 baud, then switch to 19200 baud. This is with a 16MHz crystal. The original CPU_1A1 used and 8MHz crystal and loaded more slowly.

    See the earlier question about speeding up the boot-load.

    Loading flash memory, even at 19200 baud is quite slow because each byte is programmed before the next byte is sent.

    I have found that Windows is not very good with serial communications. Avoid having too many other programs open or active during downloads. Even moving the mouse can cause a gap in the download data on a reasonably fast PC.

    I often use and older 486 PC as a terminal during development. I have noticed that the turbo speed must be set ON to ensure that characters are not lost at 19200 baud.

Q12. Can I connect a modem?

    Many embedded modems connect via a uart. The CPU_3A2 has only 1 uart (HC11 internal) which is connected to the RS-232 port when using the development board. A additional second or dual uart can be connected to the expansion bus of the CPU_3A2.

    What modem speed you need will have a large effect on the method chosen.

    Quite some time ago I connected a PC ISA modem to an HC11. It worked well. Only problem now is that ISA modems are harder to get and expensive; having all been replaced by win-modems. The HC11 will not support a win-modem.

    A second uart and RS-232 connection to an external PC modem may be the cheapest and easiest to implement as a one-off.

More Technical

Q1. Reloading Buffalo into Flash memory

    If Buffalo stops responding it is possible that theFlash memory or the CPU internal EEPRPM have been corrupted. The best thing to do is to reload Buffalo.

    To do this use the HC11Boot utility. The following procedure assumes that you have the development board. The buzzer and/or indicator LED are connected to Port-D-4. The TXD and RXD indicator LEDs flicker when data is being transfered.

    • connect the CPU_3A2 to the PC and run HC11Boot

    • insert the 2 jumpers on the CPU_3A2 (LK1 and LK2)
    • select the "erase3a.hex" file in HC11Boot (highlight it on the left)
    • press the reset button (the TXD LED should be on)
    • click "initalise HC11" (the progress bar moves and the RXD/TXD LEDs flicker)
      the buzzer or indicator LED will come on when initalise completes.
    • click "send"; wait for completion
    • click "verify"; wait for completion
    • after a short delay (about 5 seconds) the buzzer or indicator LED begin pulsing
        this indicates that the erase is complete
    • select the buffalo file you wish to reload (highlight it on the left)
        I recommend "buf_p5_3a.hex"
    • press the reset button (the TXD LED should be on)
    • click "initalise HC11" (the progress bar moves and the RXD/TXD LEDs flicker)
      the buzzer or indicator LED will come on when initalise completes.
    • make sure that the "tick for faster RAM loading" box is NOT ticked
    • click "send"; wait for completion (will take a minute or two)
    • remove the 2 jumpers on the CPU_3A2 (LK1 and LK2)
    • close HC11Boot (unfortunately you cannot run a terminal with HC11Boot open)
    • run a terminal program on the PC (Tera-term pro at 19200 baud)
    • press the reset button and the Buffalo prompt appears on the screen.
    • Buffalo is now loaded into Flash memory and startup code in CPU EEPROM.

    If you have problems, make sure that you follow the sequence above. The reset button must be pressed at the right times. If not, the bootstrap loader may not receive the HC11Boot loader and the procedure will fail.

 

 

PMB home

last updated: 08 September 2003