CPU_1A1 - F.A.Q.

I would like to thank Ryan Salsbury for contributing Technical questions Q1 to Q8.

    The code is written for the assembler that comes with the Imagecraft compiler.
    I have added a note or two in smaller blue text.

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

Contents:

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

  2. What Motorola documentation should I have?
  3. Which programming tools should I use?
  4. What do I need to supply?
  5. Can the Flash memory be used for data logging?
  6. Can the CPU_1A1 be supplied with larger Flash memory?
  7. Does the Flash memory wear-out?
  8. What about the different Flash memory chips?

  1. Speeding up bootstrap downloads.

  2. DOS copy command problems.
  3. Setting the baud rate in DOS.
  4. Using flash for startup code.
  5. Disabling or moving the eeprom bank.
  6. Configuring the chip selects.
  7. Writing a byte to eeprom.
  8. Writing to flash.
  9. How to make a program autostart from Flash memory

Basic Level

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

    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.

Q2. What HC11 documentation should I have?

Q3. 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 those of you using DOS, there is the Motorola AS11assembler, and the Qbasic ftc_ld_b.bas download program to communicate with 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_1A1 purchase.

Q4. 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, Jaycar MP-3002 or similar power supply (the development board has a 2.1mm DC power socket).

    These will be readily available from your local Jaycar or similar electrical supply store.

    I don't normally supply these as they triple the shipping weight and the power supply is normally specific to the country.

Q5. 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. I have done this by copying a flash write routine to RAM, then running code from RAM while the flash writes. I know of a few data gathering applications using the CPU_1A1 including atmospheric monitoring and vibration recording.

Q6. Can the CPU_1A1 be supplied with larger Flash memory?

    The CPU_1A1 will also support a 4Mbit flash chip (512K bytes). We normally only use 1Mbit chips due to cost and availability. All flash is expensive at the moment and in short supply. It now costs about 4x what it did 2 years ago.

    We can have the CPU_1A1 module assembled with the larger flash. There are 2 options:

    • We rework a few boards, exchanging the flash chips when only one or two are required

    • We can fit in with a production cycle where we will have to be do them in multiples of 12. The additional cost will depend on the availability and cost price of the larger flash chip at the time.

Q7. 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.

Q8. What about the different Flash memory chips?

    The vast majority of CPU_1A1 modules go into our own products, so they are assembled using the 1Mb flash chip. You can fit a very impressive program into 20 or 30 Kbytes of program space.

    Availability of flash memory has caused us problems. 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 are now using an Atmel equivalent chip made by SST (ST29EE010).

    I have kept the AMD based modules for direct sale as they are a bit 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. I use a RAM buffer to handle 2 sectors at a time.

    We have been using Atmel then SST in-house for some time now.

    The Atmel and SST flash is 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.


More Technical

Q1. Can I download the bootstrap code faster than 1200 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 9600 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 the reset vectors, why won't the cpu fetch them from flash?

    The port G pins which control the upper two flash address lines are configured as inputs on reset. You need to solder pulldown (or pullup) resistors to pins G0 and G1 to select the proper bank. 10k works fine.

     The small size of the board means that it can be easilly damaged. This can be done with a steady hand and fine soldering iron, but I would generally not recommend it.

Q5. 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;

Q6. How do I configure the chip selects to work with the cpu_1a1 module?

    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 registers and eeprom override the external sram.

Q7. 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

Q8. 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 PORTG pins. 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

Q9. 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