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. If anyone would like to see a specific question covered, please let me know and I will do my best.
|
Contents:
Basic LevelQ1. 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? MC68HC11ERG/AD MC68HC11E Programming Reference Guide M68HC11RM/AD M68HC11 Reference Manual M68HC11E/D MC68HC11 E Family Technical Data These are available at: http://www.mcu.motsps.com/documentation/index.html 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: 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 TechnicalQ1. 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. 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: 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. 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. ; 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?
|
|