Home
NMIN-2114 Single Board Computer
Contents
1. User Manual V 1 Dec 11 2002 35 Calculations and assignments of section sizes Stack end Stack begin stack end 0x0800 Stack begin stack begin 7 amp 7 heap addr Stack begin see MSL alloc c heap end heap addr 0x0000 heap siz heap_end heap_addr data begin _ data ROM begin set to shadow RAM address data size data ROM end data ROM begin data ROM begin ROM INIT START data ROM end ROM INIT START data size F user data dict heap eng first memory location for user exception table size data ROM end data ROM begin BSS 8 6 5 spi c MCore end of SPI link to HC12 Rob Chapman Nov 8 02 When the miso line is pulses low then high it is a signal to the HC12 that it should upload its current sensor readings To get the miso line low the data direction register is set the port is written to as a zero and the SPI is turned off Turning the SPI back on will make the miso pin an input and it will go high initiating values from the HC12 sensor queues include micro h include forth h include interrupt h Byte samples 9 241 ing void sir spi void service the spi interrupt if reg SPISR reg samples ind reg SPIDR if ind sizeof samples 1 RTE return from exception 8 6 6 pit c MCore PIT Rob Chapman Nov 17 02
2. err 0 clear the protects for th a one to start the command omplete EIF 0 IF 0 so flash is available for use ge e bank reg_SGFMPROT reg reg_SGF ROT reg amp 1 make sure that the protec if reg_SGFMPROT reg re err 3 return clear error flags reg SGFMUSTAT bit ACCERR reg SGFMUSTAT bit PVIOL 1 volatile INT32U t got cleared not locked g SGFMPROT reg amp 1 1 access error Protections Violation write the value to the address provided reg SGFMCMD bit CMD PAGE ERASE write to the command buffer reg SGFMUSTAT bit CBEIF 1 clear CBEIF flag by writing a one to start command wait for the command to complete while reg SGFMUSTAT bit CBEIF 0 while reg SGFMUSTAT bit CC check for errors IF 0 if reg SGFMUSTAT bit ACCERR 1 err 4 return if reg SGFMUSTAT bit PVIOL err 5 return User Manual V 1 Dec 11 2002 23 Using the GNU C compiler to compile this C source into a map file and an S record file and then passing srecord source be d Timbre Forth code P translator Source map file these two files through a Timbre script we create a Forth compileable version Flash interface written in C and compiled to an srecord flash2114 c VARIABLE a where to put flash addres
3. 808000 HERE DECIMAL CR bytes of memory left HEX START INSTALL 8 6 2 Example of C and Forth Together This is an example of a program which has interrupt handlers written for SPI and PIT in C but the control interface is in Forth MCore high speed SPI receiver for sensors Rob Chapman Nov 12 0 WORD DROP IMMEDIATE allow comments like this PIT and SPI exception handlers written in C S00A00007069742E7331399D S31A00806000760D870620079706770C60069607740B6067B7047535 S31A008060150B6017B705770AB607B60564C73477B704664639162D 31A0080602A870635279706000200CF0080721C0080722000CB0099 30E0080603F0000CB000800CB00072D 31A008060487709A707776097509A7051C677609A606B607A605616F User Manual V 1 Dec 11 2002 31 S31A008 S30F008 S31A008 S31A008 S31A008 S31A008 S31A008 S31A008 S31A008 S31A008 S31A008 5308008 531 008 S31A008 S31A008 S31A008 S31A008 S30C008 S31A008 S31A008 S31A008 5306008 S31A008 S31A008 S30B008 5705008 SPI 60D087052E 60 5372 071 60FA870512762036 605D170C67E8031267200 607272240080722000CBO 607C24F0007D1221 60910612263476B6 60A60F72E8 60BB071272 617B 6190 610F70007E 0 6124207000CF008061AC008005080 613980607C81 613C7601 6151 123E73087F0 7 06200787060 0073087 007200730 7B705000200CF00CB00030080B8 00526 E123D7F290142762983067529870597 07200797051227240712720
4. 8 3 4 Interrupts Calling Forth As for calling a Forth word from an interrupt this is doomed to fail at some point since not all Forth words including the virtual machine are not interruptible without some extra context savings This all adds overhead and goes against keeping interrupts as short as possible If you keep your interrupt simple and 1 Pardon the hand coded horizontal assembler it takes a while to get use to it The next step would be to build a small assembler throw away the code and compile the comments horizontally User Manual V 1 Dec 11 2002 21 in assembler then they have a greater chance of working and meeting system time constraints With the alternate register set a parallel Forth environment which ran the same words and shared the same variables but had different stacks and program counters could be built in the sketch board of the mind This parallel Forth could then be relegated to interrupts only and then you would be able to run one Forth from interrupts and one from the command line Or better there is just one Forth and it runs from interrupts only 8 4 Flash Programming On the 2114 there is 256K of programmable flash and 32K of RAM The Flash can only be programmed by running programming software entirely out of RAM or from the opposite 128K block that is being programmed The programming procedure is fairly simple and is expressed here as a C program MCore 2114 flash routines Rob Chapman No
5. STANT FLWORD 2 ALLOT COMPILE F WORD end of support code IMMEDIATE user program begins here Test use and discard ELS DUP U 12568706 60479704 to the C routines THEN t all be empty THEN remember the beginning of the word set fdp to next word unlink relink below firstword link to firstword words move word change pfa pointer update flash pointer update dictionary pointer at reboot time a Hello will be emitted and the word that did it be part of the dictionary HI Hello HERE CONSTANT DPO STARTUP DPO DP 3FFO FL t o HI NFA CONTI EXT STARTUP CFA 3FF4 FL h CHE S will hook into boot start vector User Manual V 1 Dec 11 2002 26 A44A 1F800 FL STARTUP CFA 1F804 FL hook into auto start vector 8 5 2 UNBOOT2114 F Utility for eraseing boot tags in flash Rob Chapman Au072002 put flash programming tools in upper memory COLD HEX Flash interface written in C and compiled to an srecord flash2114 c VARIABLE a where to put flash address VARIABLE d where to put flash data VARIABLE err where error codes are stored 1 5 or 0 21C CONSTANT CLOCK D00002 CONSTANT SGFMCLKD DECIMAL INIT FLASH J initialize the flash
6. ALIGN 0 400 vector table start vectortable vector table end gt VECTORS main application text ALIG UE 0 4 rodata ALIGN 0x4 sinit STATICINIT ALIGN 0x4 ROM INIT START TEXT Map to VECTORS memory section Put the vector map at the very Align table on 1024 byte boundary 3 MCore requirement File of vector table 0x000 OxlFF Application Code Map to TEXT section 0x200 tell linker generate the Load address other than the real address main app data ALIGN 0 4 __data_ROM_begin data vtables exception ALIGN 0x4 exception table start EXCEPTION exception table end data ROM end DATA maxforthmap ALIGN 0x400 maxforth vector start forthvector maxforth vector end _ gt MAXFORTH main app bss bss begin bss pss end AT ROM INIT START Data Section A section of data to be copied to RAM Sets location variable used in rom copy Just include data in all modules for now or to be copied to RAM Put the vector map at the very beginning Align table on 1024 byte boundary per File of vector table to MAXFORTH memory section OxlFCOO Uninitialized data space
7. Bsa 29169 22 22 UO 120 029819 620 WO S29 AGE sioyoedeg ssed g euonppy 49 0 085 80193NNO9 021 palesu S ZN JI 9LP joeuuoo jou 0q 310N SYIIZZZEdS Y E 1 EBYEXYN 7 1 CSPEXVIN re D recu sn xllfx 3 y z amp 11 Dec 11 2002 User Manual V 1 8 0 Examples These examples may be typed in interactively or cut and pasted into the terminal window if you are using MaxForth Alternately they can be translated to the language that you are using to program the microcontroller with There are two manuals PDF files from Motorola that you need at your disposal to understand the 2114 microcontroller Some of the subsequent tables and diagrams are from these sources 1 MMC2114 Technical Data This document describes the peripherals including the interrupt controller and the registers memory mapped so accessible from Forth 2 MCORE Reference Manual This document discusses the core CPU instructions and internal registers not memory mapped so accessible only from assembler 8 1 Reading from the A D port For this example we will consider the simplest way to get an A D reading get A D reading A D channel 0 display reading This involves setting up the A D registers so it is ready to go requesting a read of a channel waiting for that channel to complet
8. CODE TEST PIT mvi r4 0 lrw r3 pIFRL stl r4 r3 0 Ilrw r4 ctr 60047303 94037404 addi r4 0 lrw r3 pctr stl r4 r3 0 rte 20047302 94030002 ptr IFRL petri 4 ctr 0 IFRL HERE 4 0 END CODFE yt TICK TEST PIT 18 Now we set up a vector table and test the interrupt TEST PIT 1 OR 807C28 OK 1 NIER OK 807C00 1 CRN OK 80000140 0 CRN OK TICK 0 OK 40000000 IFRL TICK 1 OK 40000000 IFRL TICK 2 OK Every time we force the interrupt on with IFRL it gets serviced and the tick counter increments Now we are ready to hook into a peripheral 8 3 3 Setting up a Peripheral Interrupt For this example we will use the first programmable interrupt timer to generate a periodic interrupt which increments a variable From the documentation we find that we need to set PCSR to run the PIT and the interrupt routine needs to write pit PIF to the PCSR to reset the interrupt So our code will look like this CODE SIR PIT mvi r4 13 lrw r3 pPCSR stb r4 r3 0 Ilrw r4 ctr 60047303 B4037404 addi r4 0 Ilrw r3 pctr stl r4 r3 0 rte 20047302 94030002 C80001 HERE 4 O END CODE TICK SIR PIT Co 18 Now we set up a vector table and test the interrupt SIR PIT 1 OR 807C28 OK 1 NIER OK 807C00 1 CRN OK 80000140 0 CRN OK 9FFFF C80000 OK TICK TICK TICK 31 36 3B OK
9. NMIN 2114 Single Board Computer User Manual V 1 NEW MICROS INC 1601 Chalk Hill Road Dallas Texas 75212 Tel 214 339 2204 NMIN 2114 Dec 11 2002 Table of Contents L0 OVerVIQW 5o haeo b CE ERE edt HS SSS ae 3 1 1 Noted microcontroller 3 1 2 Incl dedg FIGS Ks Sette eL cc are ate eder 3 2 0 Getting 4 3 0 Memory 5 4 0 Programming the Board 5 4 1 ONCE Connector and Parallel 5 4 2 S Records and the Serial Loader 6 4 2 1 Downloading S Records With 7 4 2 2 Hooking Into Autoboot 7 ADB MAGS LN MEER DUO RE 8 4 2 4 Quick 8 A 25 Boot ENUY eisa e ae e Bios wads LEAN ee Su Eod 8 4 26 Auto uo ke ag oa feoda t eps eek asad 8 4 3 On board Development System 8 5 0 I O Connections and Jumpers 8 6 0 Board 1 10 7 0 5 11 8 0 Examples cce sees esd leva sotawradeee EDT EAT 12 8 1 Reading from the A D port 12 8 2 Control 5 5 13 8
10. Pulse accumulator input Write PAIF 1 or access PAC if TFFCA 1 PAOVF Pulse accumulator overflow Write PAOVF 1 or access PAC if TFFCA 1 35 EPORT 36 37 38 39 Edge port flag 3 Write EPF3 1 EPF4 Edge port flag 4 Write EPF4 1 EPF5 Edge port flag 5 Write EPF5 1 EPF6 Edge port flag 6 Write EPF6 1 EPF7 Edge port flag 7 Write EPF7 1 Figure 11 This table has the rest of the interrupts from the other peripherals If you want to develop a timer ticker to provide a solid time base you could use one of the PIT timers To make sure you have the interrupt machinery right before you play with the PIT you should test it with the interrupt force register For PIT1 this is bit 30 or in hex 40000000 IFRL this forces on the interrupt bit for the PIT1 peripheral If we check out the interrupt controller registers we can see that we have a normal interrupt pending in the ISR lower 16 bits of ICR the pending interrupt is lowest priority in the IPR register and it is a normal interrupt as shown by the value in NIPR ICR U 80000200 OK IPR U 1 OK NIPR U 1 OK At this point we are ready to flip the switch on the CPU and test out an interrupt unless you have done that already and crashed and burned Before we switch on interrupts we need to provide a vector for User Manual V 1 Dec 11 2002 20 the interrupt to jump to and also a way of turning off the source of the interrupt
11. lrw r4 ptr mfcr r3 crn stl r4 0 jmp r15 ptr 4 0 74021003 930400CF HERE 4 0 END CODE MFCR read control register into parameter field CODE lrw r3 value mtcr r3 crn jmp r15 value 0 73021803 00CF0000 0 END CODE MTCR write control register from parameter field Forth interface Create an opcode with the given control register and then store it in the code word before running it control register contents return contents of control reg 10 74021003 OR MFCR gt R FCR R C CRN value control register store value into control regt 10 73021803 OR MICR gt R Re R gt 8 MICR CREATE MNEMS 13 4 ALLOT pointers to 13 mnemonics HERE SWAP 4 MNEMS 22 WORD C 1 ALLOT ALIG SP SPR ABS 1 DUP HERE SWAP NOT AND DP 0 1 M VBR 2 EPSR 3 M FPSR 4 M EPC 5 FPC 6M SSO 551 8 M 552 9 553 554 B GCR C M GSR ALIGN Dump all the control registers CREGS CR DODO I2 R I CRN 9 U R I 4 MNEMS COUNT SPACE TYPE CR LOOP User Manual V 1 Dec 11 2002 13 PSR CRO VBR CR1 EPSR CR2 FPSR CR3 EPC CR4 FPC CR5 550 CR6 551 CR7 SS2 CR8 SS3 CR9 SS4 CR10 GCR CR11 GSR CR12 Figure 3 The contro
12. C CRZ SR C DR 2DROP CC C SPI 0 DDRS 6 CRI PORT SPI 1 DDRS C 0 PORTS C SPI ind C samples 20 DU ES 0 ind PORT SLAVE EST INI SLAVE R DR W SR DR C 2DROP DR C BEGIN SR C8 UNTIL S SR CR P PORTS C 8 0 DO DUP 80 AND IF 1 ELSE 0 THEN 2 LOOP DROP Q BORTS C P Z BEGIN BEGIN SR C TERMINAL OR UNTIL S TERMINAL UNTIL X 0 DO I W LOOP Take a run at it 1 CRN VECTORS 80 CMOVE grab current vectors sir spi 1 OR VECTORS 22 4 INSTALL SPI VECTOR WITH AF BIT SET sir pit 1 OR VECTORS 21 4 install PIT victor VECTORS 1 CRN SET VBR 2 PLSR5 C LEVEL 2 FOR SPI 1 PLSR30 C LEVEL 1 FOR PIT 6 NIER ENABLE INTERRUPTS 0 ICR H NV VECTORED INTERRUTPS User Manual V 1 Dec 11 2002 33 80000140 0 CRN ALLOW NORMAL INTERRUPTS SLAVE SET FOR SPI RECEPTION SR CLEAR UP ANY OLD DATA PIT START THE PIT BULL PORT TURN OFF SPI SET MISO LIN TES PUT THE MISO LINE HIGH AN E LOW D THEN SWITCH ON SPI INTERRUPTS If you download this file it will install interrupts for PIT and SPI as well as create words in the Forth dictionary to access the C functions The details
13. You can autoboot an application by leaving a vector to it at location 0x4000 The startup boot loader will detect this vector and then jump to the location that the vector is pointing to When MaxForth is installed it has a vector at that location To get to the serial loader from MaxForth type in FLASH and hit enter To get back to the serial loader from an application execute the vector stored at location 0x190 in memory The application area 0x0 4000 0x1 FFFF can be erased using the serial loader without the boot loader being removed from memory This is the e option Tel ccm If MaxForth is loaded you can check the memory at location hex 4000 by HEX 4000 1 DUMP 0112 3 4 5 6 7 8 9 A B CD EF 4000 00 00 91 08 72 04 4 02 30 04 60 03 1E 34 01 44 r 0 4 D OK MaxForth occupies the space from 0x4000 to about OxE300 At location 0x4000 is the start vector for MaxForth which is what the bootloader looks for when booting If the location is OxFFFFFFFF then it is assumed that there is no application loaded and the serial loader is run MaxForth can be replaced by erasing it and writing a new application in its place making sure that the startup vector for the new application is at 0x4000 If you want to hook into the Forth autoboot system then there are several places where you can do this quick entry allow setting of COP and other write once registers on the micro boot entry MaxForth has been setup and
14. e eS zool e e 000 gt aT ae e eoe cz zoo ee N 9 e eo Le e e odole a III Ag qu eo o sip 9 A35 0 I o9 oes Peels 7 0 e 2 Cote 5 ue o o0 iste oe g lt eo jee DU ae x pp oe a 08 9 8 0000000000000 E el ojo e e ei ie eee ojojojo eee oe S19 5 YSG Bi eo QNS o wo N o vo N o 5 i 3 g g 8358 3 8 5 E 5 g S amp Unit in Inches 10 Dec 11 2002 User Manual V 1 7 0 Schematic 1301 433HS m 90988 on wa NO TVECNINN NI m pm SYOOW XL NUD 1091 OX SODIURGU IV nnne ME gt D 9 s v c dd T wot 121 OL VNIX OH 2 8 9071807 SSSA s 3007 une 9519 on s UN s WIND S SIN SIN o IN we OsW ABISN 05 9 55 139 8 AOUO OVLE 8 0149 8085 13539 1510897 IOWO NASOOA oar r i Pi nee jaan EEEL
15. 3 Implementing an 14 8 3 1 Setting up the CPU 15 8 3 2 Setting up the Interrupt 17 8 3 3 Setting up a 21 8 3 4 Interrupts Calling Forth llle 21 8 4 Flash 22 oo Auto Install Program sess neresi e os S 25 8 5 1 AUTOBOOT F bu Sk be Seek i ded E Wa es 25 8 5 2 UNBOOTO2 TIME sire EE ap ae inal aa eed 27 8 6 Advanced 27 8 6 1 SBEGBOQO TE iu bd clea Pada oS hh 2 WA wee De da ob dye Rus 28 8 6 2 Example of C and Forth Together 31 8 6 3 Makefile ler kr ire RR RR REGES 34 8 6 4 34 par eoa Dos e She or Mas A ne dr 36 User Manual V 1 Dec 11 2002 8 6 6 pitc 8 6 7 forthh 8 6 8 micro h 8 6 9 interrupt h 8 6 10 words c 8 6 11 makewords c 36 37 38 40 40 40 User Manual V 1 Dec 11 2002 1 0 Overview The NMIN 2114 single board computer provides you with plug and play access to the powerful 32 bit Motorola MMC2114 microcontroller The computer board provides power regulation RS232 and RS422 serial support and an LCD connector The microcontroller includes the following built in capab
16. A periodic timer is used to get sensor values from the HC12 The interval is settable from 2 ms or more include micro h include forth h User Manual V 1 Dec 11 2002 36 include interrupt h extern ind Cell sample_no sample number void sir_pit void service the pit interrupt sample increment sample number ind 0 reset index for sample array reg SPICR1l reg 6 turn off SPI to gain port control reg SPIDDR reg 1 set the MISO line as an output reg SPIPORT reg 0 make sure its zero reg SPIDDR reg 0 turn it off now reg 1 0xCC turn spi back on reg PCSR1 bit PIF 1 turn off pit interrupt RTE return from exception 8 6 7 forth h header file for forth c Rob Chapman Feb 2 2000 17 mar 02 bjr changed user dict from Cell to Byte 28 apr 02 bjr removed UD SIZE dict now define in linker file f Since long long is not universally supported the double cell support can come from either long for 16 bit cells long long if supported for 32 bit cells or forth double number support if no double support is available For this reason Duo and U_Duo are defined in micro h Portable type definitions typedef unsigned int Bits for bit fields typedef unsigned char Byte a byte typedef unsigned int Cell default memory unit ok as pointer typedef Cell Flag a flag 0 or non zero typedef s
17. DROP record loader VARIABLE ls last srecord VARIABLE g go address from s record TASK CFA default G g EXECUTE OF i uem BEGIN TIB BEGIN KEY DUP BL lt 0 WHILE OVER 1 REPEAT DROP echoless 0 IN DUP TIB DUP SPAN TIB 0 OVER imitate query TIB XOR UNTIL skip blank lines User Manual V 1 Dec 11 2002 30 OINPUT WRITE OUT 0 DUP gt IN DUP TIB TIB C Szero a a 2 X 2 X DROP S1 a a 2X 3 gt R 4X R S S2 2X4 gt R 6X R S S3 2X B5 25R 8X R gt Sloy S7 a a WRITE OUT 2 X DROP 8 Xg OINPUT 58 a a WRITE OUT 2 X DROP 6 OINPUT S9 a a WRITE OUT 2 X DROP 4 Xg OINPUT Shit m BEGI 20 TIB 2 DUP 1 0 IF DROP Szero DROP ELSE DUP 1 1 IF DROP 51 DROP ELSE DUP 1C2 IF DROP 52 DROP ELSE DUP 1C3 IF DROP 53 DROP ELSE DUP 1 7 IF 1s 87 EXI ELSE DUP 18 IF 15 S8 EXI ELSE DUP 1 9 IF 1s S9 EXT ELSE 2DROP INTERPRET THEN THEN HEN THEN THEN THEN THEN AGAIN Half word support HE a n COUNT 100 SWAP CR OR H n NVa gt R 100 MOD R C R gt 14 C n HERE 2 ALLOT H Boot program START 1 accumen INIT FLASH CR Boot V 3 CR S ls 1 6 gt IF G THEN
18. a long download Your mileage will vary 4 1 ONCE Connector and Parallel Port Using the MCORE Cable from P amp E Micro or equivalent plug it into the parallel port of your computer User Manual V 1 Dec 11 2002 5 through a parallel port cable and the ONCE port on the computer board making sure to orientate the triangle on the pin header to pin 1 on the board which is marked by a square solder pad on the bottom of the board Apply power to the board When disconnecting from the board make sure it goes through a power cycle before you try out the downloaded software since a reset is not enough to regain control of the microcontroller after interacting with the ONCE port If you already have CPROGMCZ running click reset the chip If you start it up it will reset the chip and proceed to the next choice which is to read in a configuration file The file that works with the board is the 2114 256k MCP file which should be in the directory for configuration files Next you will need to erase the module specify an s record to download and then program the module To test out the software you must disconnect the ONCE connector and power cycle the board The serial loader file can be downloaded in this manner and then used to program the flash ROM using the serial port as described next Check the help screens for more details 4 2 S Records and the Serial Loader Using the serial loader you can download s records that have been created by a C
19. are in the following C files and only will work for this version of MaxForth The C code has been compiled with a port of the GNU C compiler for Mcore The makefile is included 8 6 3 Makefile This makefile was used to invoke the GNU compiler and compile the files pit c spi c makeword c words c NAME test io S mv I Mcore CC gcc mcor I N I Mcore I Mcore LD gcc mcore nostartfiles T gnulink lcf AR ar MCORE AS as MCORE GS gasp MCORE RM del SUEFIXES 3 4 0 G S CFLAGS c 03 AFLAGS ahls pit pit c gnulink lcf Spi c makeword c words c 5 S CFLAGS Wa ahls Wunknown pragmas pit c oformat srec Map pit map gcc mcore Ttext 0x806000 nostartfiles Wl o pit s19 pit o spi o makeword o words o gnulink acf forth h micro h 8 6 4 gnulink acf This file uses a linker language to describe what the target memory looks like and how the sections of code data and empty space fit into it all MEMORY VECTORS ORIGIN 0 00004000 TEX RX ORIGIN 0x00004004 DATA R ORIGIN 0x00010000 MAXFORTH R ORIGIN 0x0001FCO00 BSS RW ORIGIN 0x00800000 damn deadstrip prevention SECTIONS cot di Hi 0x00000004 0x00001000 0x00001000 0x00000400 0x00001000 User Manual V 1 Dec 11 2002 34 beginuenyotmap per
20. it will boot up next time You have the flexibility to keep the serial loader program as part of your end system or to remove it and replace it with another program Quick Tip Applications If you are using the serial loader to test out your application which starts with a vector at location 0x4000 then just use e and f download your application If you download an application reboot and nothing happens you can recover to the serial loader by shorting out PA7 to 43V on the J2 connector with a jumper or equivalent and pressing the reset button You will be taken back to the serial loader where you can erase your errant application and try again User Manual V 1 Dec 11 2002 6 4 2 1 Downloading S Records With X Modem The serial loader uses the X Modem protocol to transfer data from the host computer to the board This allows for error recovery and pacing to be done by the protocol giving you a more robust download protocol Depending on your host program and its defaults the setting may be not right Try it first and if it doesn t work modify some of the settings To install a fresh copy of MaxForth and erase all the flash from 0x4000 to Ox1FFFF do the following get to the serial loader from Forth by FLASH or by resetting with PA7 to V press e wait till done then press f download the MaxForth s record with Xmodem 5 wait till done then press reset with PA7 not connected to V 4 2 2 Hooking Into Autoboot
21. to code like the inner interpreter union param body 1 points to an array of pointers to these Forth whatever Param ifdef DUO Endiandependance for the double integer guys Forth model is top is upper cell and next is lower cell Little endian would have it switched from big endian Forth These little ditties run independant of endian and convert to duos and back from memory Trick is no conditionals Duo asduo Cell void toduo Duo Cell fendif 8 6 8 micro h M2107 Settings include mmc2107 h include m2107 h ifndef MICROH define MICROH define MCORE User Manual V 1 Dec 11 2002 define DUO 1 typedef signed long long Duo double the integer power typedef unsigned long long U_Duo double the cell power eeprom no here define EEPROM_START 0 wrist canine chronometer define COP OFF reg WCR bit EN 0 disable watchdog timer external RAM define EXTERNAL RAM assembler to forth call define ATO4 OxE198 for hcl2 or mcore extern unsigned int F user data dict user dictionary define SETUP DICTIONARY Cell dppfa Cell amp F user data value from linker file N Cell fencepfa Cell amp F user data dict value from linker file serial io define SEND X reg SCIIDRL X define RECEIVE reg SCI
22. you will need to reset that bit Bit 31 30 29 28 27 26 25 Bit 24 Bit 7 6 5 4 3 2 1 139 IF38 IF37 IF36 IF35 IF34 IF33 IF32 0 0 0 0 0 0 0 0 Writes have no effect and the access terminates without a transfer error exception Figure 8 IFRH register contains the upper 8 interrupt source force bits User Manual V 1 Dec 11 2002 18 Read Write Reset Read Write Reset Read Write Reset Read Write Reset Figure 9 IFRL with the first 32 interrupt force source bits Source wesue Fea Source Deserption Flag clearing mechanism Write PF1 0 after reading PF1 1 2 TE Write PF2 0 after reading PF2 1 7 on memwreemn Road SRL OR 7 v I Ww memernen freseo aerem _ 8 Figure 10 This table shows the first 16 interrupt sources and how to turn them off User Manual V 1 Dec 11 2002 19 Timer channel 0 Write 1 or access IC OC if TFFCA 1 N Timer overflow Write TOF 1 or access TIMCNTHIL if TFFCA 1 PAIF Pulse accumulator input Write PAIF 1 or access PAC if TFFCA 1 AOVF Pulse accumulator overflow Write PAOVF 1 or access PAC if TFFCA 1 z 23 Timer channel 0 Write COF 1 or access IC OC if TFFCA 1 24 Timer channel 1 Write C1F 1 or access IC OC if TFFCA 1 25 Timer channel 2 Write C2F 1 or access IC OC if TFFCA 1 7 28 29 21 Timer overflow Write TOF 1 or access TIMCNTHIL if TFFCA 1 PAIF
23. 1422C872E 0D12748705A60EB607200E20079705122724 01420F42E7F4751B87052407A6073476B607F5 372A07E809125660058706B507200797062E 7 9751187059307203797051276207696077 96059D1720779705006D20F000CF24AF 95 18 1A 8760687069E0720379706006EA5 080050C0000488800 E7F0B720E730E7F0A720E730E ind C 61667F0872 ECO080 61D6F00120 61EB80AD 61EC68656C6C6F0000006 6201616D706C655F6 6216725F70697400DE 6146D3 0080600097 0F730F7F078F002070 Hj 96E640073616D706C65730073 E6F0000007369725F7370690073691 0CF24709F00720B730C7F0C72B8 06 89 0CF00807220008061AD 613C0080607C008061F40080610E008061F887 00807224008062000080721C0080620C008060480058 61A5806214 61AC122512272E372A07E808F0012002A7022A0 7E7FCO58D 61C15200CF2032860277071C671F67740616472A0 7EFF7D3 02A7022A07E7FC055200CFFEFEFEFF808080BF 61 E2 Assembly interface use mtcr and mfcr to transfer contents of control CODE MFCR lrw r4 74021003 CODE registers to and from memory read control register into parameter field ptr 930400CF HERE write control register from parame mfcr r3 crn lrw r3 value 00cF0000 O 73021803 mtcr r3 crn etl r3 t4 0 4 0 END CODE ter field jmp r15 value 0 END CODE jmp r15 ptr 4 0 Forth inte
24. 16 S 0 SP us u uo 0 VEC RESET 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 TC 0 5 MM EE Ic IE 0 FE 0 0 C RESET 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Figure 4 Program status register PSR accessible only from assembler The EE and IE or FE bits must be set for interrupts to work To enable interrupts at the CPU you must set the EE exceptions enabled and one or both of the IE interrupt enable or FE fast interrupt enable bits With the EE bit set in the event of an interrupt the PC program counter and PSR can be saved into two registers on the CPU This limits interrupts to a depth of one unless some interrupt register management is added to push these two registers onto the stack and then restore them later The IE bit enables normal interrupts while the FE bit enables fast interrupts 80000140 0 CRN enable exceptions and normal interrupts 31 10 9 0 VECTOR BASE RESERVED RESET 00000000000000000000000000000000 Figure 5 The address in the VBR is the start of the exception vector table Since the lower 10 bits are zero the vector table can only start on address evenly divisible by 1024 0 0x400 0x800 The VBR can be set to a RAM location for developing your interrupt routine and then later set to the final place for your working interrupt routine You can put this near the top of the internal ram by 807C00 1 CRN This puts the vect
25. 8 includes jumper A B C The Jumpers A B C allow both RS 232 drivers for COM1 amp COM or 1 RS 232 and 1 RS 422 driver for either COM Jumper A allows RS 422 selection of either TxD1 or TxD2 of SCIO or SCI1 serial output signals respectively Jumper B is the serial input to SCI1 labeled RxD2 it is defaulted to RS 232 but can be jumpered the other way for RS 422 Next to Jumper B is 5V amp GND This can be used for a test point or external 5V source to power a probe Use a paper separator for protection Jumper C is the serial input to SCIO labeled RxD1 It is defaulted to RS 232 but can be jumpered for other way for RS 422 J9 Flash voltage supply Connects when flash needs to Erase Program Open when flash does not need to erase program or for Write protection J10 serial connection for SCI1 DB1 serial connection for SCIO J12 RS 232 shut down control input Drive high for normal operation Drive low to shut down the drivers This can be controlled by PA2 or jumper to 3V for normal operation default J13 RS 422 connector J14 Jumper to GND default for RS 422 receiver always or jumper to PA6 as RS 485 transmitter Receiver control signal J15 connects to pin 1 of RS 232 U2 This pin can be used to enable disable the receivers for the RS 232 interface For normal operation this pin must be low By default J15 is open and this pin is pulled down through R5 To disable the receivers J15 can be conne
26. AM32K serial loader system 80 0000 0x0003 FFFF eS 03 FFFF Application Internal 01 0000 Flash 256K MaxForth and or Application 0x0000 4000 00 4000 boot loader serial loader 00 0000 Figure 2 After booting the RAM memory map either belongs to the serial loader or the MaxForth application 4 0 Programming the Board When the board is reset it executes the program pointed to by the vector at location 0 In a loaded board this will be the boot loader which will either start the serial loader or MaxForth When MaxForth starts it checks to see if there is an application present and runs it or just runs MaxForth There are several ways in which to program the board 1 2 3 4 download s record through the ONCE connector and the PC parallel port using programmer such as CPROGMCZ download s records using the embedded serial loader and a serial port with HyperTerminal interact directly with the microcontroller and download source code to the on board development system MaxForth through a serial port and HyperTerminal download a mixture of s records and Forth using the Forth s record loader SRECBOOT F When downloading text files to the board using the text download protocol make sure the delay per line is at least 100 milliseconds You can risk having lines missed if you go to fast but with some setups it is possible to use smaller line delays which has a nice effect on
27. CLKD register CLOCK 200000 DUP 60 gt IF 8 64 THEN SGFMCLKD C INIT FLASH run so flash can be programmed HEX HERE program a 32 bit word with d at a 24709E00 y 743E6007 9704773D 83072D17 16373ED7 60121225 1B7501F5 01657639 C7061657 D706C706 C6061657 OF76E802 9204FOlF 75358705 7 60279704 F0187732 87079703 76328706 2D8E35FE 16E735D7 970687 35F79705 870537F7 E0041256 870637F7 EFFD7627 870637E7 EFFD8E 207000CF Oo HERE erase a page containing a 74216007 97047621 C7062E17 D706C706 C6062E17 OF76E803 60379704 OOCF751C 870535C7 97058705 35D79705 77178607 77198707 97067618 87062D83 35 31637 35E79706 870535F7 97058705 37F7E004 12568706 37F7EFFD 760E8706 37E7EFFD 760C8706 3FC72E17 2A17E003 60479704 00 8706 3FD72E17 2A17E002 60579704 OOCF0000 err 00D00010 00D0001C 00000020 CODE ERASE PAGE END CODE LATEST PFAPTR CFA connect to the C routines CODE CPROGRAM WORD END CODE LATEST PFAPTR CFA PROGRAM WORD a IF CPROGRAM WORD ELSE d 0 at zero THEN FL n a a d PROGRAM WORD UNBOOT a DUP DUP A44A SWAP A55A OR IF DUP 0 SWAP FL ELSE DROP THEN UNBOOTS cl
28. EFFD 760E87 35 06 7 3 E79706 870535F7 97058705 E7EFFD 760C8706 3FC72E17 OOCF8706 3FD72E17 2 17 002 60579704 OO0CF0000 a 00000010 00D0001C d err CODE ERASE PAGE I D COD Ij CODE CPROGRAM WORD as ROGRAM WORD a FL n a E LATEST PFAPTR CFA art CPROGRAM WORD d PROGRAM WO END CODE LATEST PFAPTR CFA ELSE d G FLMOVE 4 0 DO gt R DUP R FL 4 Flash memory interface VARIABLE FDP VARIABLE flast RD 37F7E004 2A17E003 00D00020 connect at zero R gt 4 LOOP flash dictionary pointer points to last entry Find empty space in Flash RO 40000 10000 FLBLANK a E400 DO FF I 40 OVI FF IF DROP I 40 LOOP DUP 1 FLBLANK FDP UNDO 800 ER SWAP DO LEAVE THEN 2DROP aux high low I AND LOOP mus IF CR Flash is full CR FLWORD LATEST gt FDP 3 3 NOT AND FDP R PFAPTR LFA CONTEXT firstword LFA R PFAPTR LFA FDP firstword LFA FDP R R PFAPTR R FDP HERE R FLMOVE HERE R8 FDP R gt DP ROM it all with auto rom CONSTANT CONSTAN CREATE HERE CO VARIABLE CREATE
29. IDRL define SENT reg SCIISR1 bit TDRE define RECEIVED reg_SCI1SR1 bit RDRF define 0x80 define RDRF 0x20 define FREQ 32 frequency for 2114 chip define BAUD57 FREQ 1000000 16 57600 define BAUD96 FREQ 1000000 16 9600 define BAUD19 FREQ 1000000 16 19200 define SET SERIAL COP_OFF reg SYNCR reg 0x2000 reg_SCI1BD BAUD19 select the baud rate reg_SCI1CRl reg 0x00 reset values 8 N 1 N reg SCIICR2 bit TE 1 enable transmitter N reg SCIICR2 bit RE 1 enable reciever if reg SCIISR1 reg transmitter is actually enabled here N while reg_SCI1SR1 bit TDRE wait for TDRE to go high define flash void 0x190 vector for flash program module define ALIGNED a Cell a 3 amp 3 Stack sizes define RS_SIZE 64 define DS_SIZE 64 define FS_SIZE 8 User dictionary size User Manual V 1 Dec 11 2002 39 define UD_SIZE 1000 Environment define DICTSTART 0x800000 define DICTEND Ox81FFFF define QUICKTAG Ox3FFC define QUICKVECTOR Ox3FF8 define BOOTTAG Ox3FF0 define BOOTVECTOR Ox3FF4 define BOOTSTART 0x10000 define BOOTEND OxlFFFF endif 8 6 9 interrupt h define RTE asm rte exit interrupt 8 6 10 words c MCore interrupt routine interface include forth h include makeword h extern Byte ing exter
30. always start flash FL START FL fire once autostart flag for startup ESTOE CFA FL 4 FL FL TASK 8 FL FL sys start FL RAM START DUP sys size C FL save application image in flash E the same way R restoration vector tor can be written by INSTALL save system variables RAM START save length amp dictionary null vec FLMOVE FL SEEMOVE Sys size sys size 10 FL INSTALL tick FLSAVE 8 FL FL COLD AUTOBOOT 0 FL START FL turn off autostart flag cold boot record parser X0 SWAP 0 DO 10 gt R COUNT 30 DUP 9 gt IF 7 THEN R gt LOOP Memory interfaces VARIABLE accumen accumulate 4 bytes then writ VARIABLE storage point to where it is to be stored WRITE OUT storage 40000 U lt flash write IF accumen 1 XOR skip if nothing set else program flash IF storage 3 NOT AND accumen PROGRAM WORD THEN ELSE accumen storage THEN RAM write 0 storage 1 accumen initialize values again BYTE b DUP storage XOR 3 NOT AND same block of 4 IF WRITE OUT THEN DUP 3 NOT AND storage 3 AND accumen C Sk a t Naa gest 0 DO R 2X R BYTE gt 1 LOOP
31. and application support Rob Chapman Nov 21 2002 This small program consists of the following tools gt an s record loader for 50 51 52 53 S7 S8 S9 records for RAM any line not starting with S will be passed to the Forth interpreter gt a code to FLASH saver restorer with autoboot gt saving and restoring static ram images application auto start From Reset to application running reset MCU jumps to MCore bootloader routine calls MaxForth startup routine scans for secondary boot and finds image in FLASH COLD HEX Image and properties HERE CONSTANT RAM START start of user dictionary 10000 CONSTANT FL START start of Flash above Forth 1BFFF CONSTANT FL END just before forth vector at 1FC00 Flash interface written in C and compiled to an srecord flash2114 c VARIABLE a where to put flash address VARIABLE d where to put flash data VARIABLE err where error codes are stored 1 5 or 0 21C CONSTANT CLOCK D00002 CONSTANT SGFMCLKD DECIMAL INIT FLASH initialize the flash CLKD register CLOCK 200000 DUP 60 gt IF 8 64 THEN SGFMCLKD C INIT FLASH HEX User Manual V 1 Dec 11 2002 28 HERE 24709E 01657 37F7E 97068 EFF D8E 6 0 7 HERE 742160 00CF75 87062D OOCF87 err 37F 7EFED program a 32 bit word with d
32. at a 0 743E6007 9704773D 83072D17 C7061657 D706C706 C6061657 60279704 F0187732 87079703 35F79705 870537F7 E0041256 207000CF 16 OF 76 87 3 O U erase a page containing a 07 97047621 C7062E17 1C 870535CT7 7 970587057 83 35F31637 35E79706 760E8706 37E7EFFD 3FD72 2A17E002 00D00010 C6 77 97 D706C706 35D79705 870535F7 760C8706 60579704 00D0001C 06 E17 CODE ERAS E PAGE D CODE R CFA LATEST PFAPT 1 CODE As ROGRAM WORD MOVE ROGRAM WORD END CODE LATEST PFAP IF CPROGRAM WORD ELSE d a nNa a PROGRAM WORD 4 0 DO Q R FL 4 gt RO DPL RO DPL tartup service IN CONSTAN 4 CONSTANT sys end mm sys start start of Sys E C EM 10 a nd sys start CONSTANT sys size 0000A44A RESTOF si E must point to saved image of r O0CF0000 IR CFA 373ED7 76E802 60121225 9204FO1lF 1B7501F5 75358705 328706 2D8E35FE 16E735D7 0637F7 EFFD7627 062Eb17 178607 058705 C72E17 OF76E803 77198707 37F7E004 2A17E003 00000020 connect to the at zero 4 LOOP 2DROP system varia
33. bles end of system variables ze of variables stor main startup word must be a PFA copy of sys size RAM locations in system sys size length of image sys size image of code ERASE erase FLAS NI DO Ia ERAS E PAGE mS gt FL RAM ram flash STAR L START 10 sys size Es ESTO RE can t call nonexistant words so C sy Sy Sy Sy 8 UP R v RAM START F s start LITERAL iL s size 10 F LI s size FL FL LITERAL IF DROP run main program s ERAL RAL 5 CMOVE it LITERAL ERAI LITERAL s size tart of dict CMOVE S ASK THEN EMO EL s xcd 400 LOOP LITERAL is used tart of system image tart of system variables restore system RAM image start of dict image Space after exiting restore like FLMOVE but you get to see it 870637E7 60379704 97067618 12568706 60479704 C routines THEN convert ram address to saved location in flash restore dictionary image to RAM User Manual V 1 Dec 11 2002 100 MOD DUP IF SWAP gt R DUP gt R 0 DO I 1 2DUP 100 FLMOVE R gt R SWAP 1 FLMOVI 100 gt R 100 R gt LOOP THI Gl FLSAVE
34. can be augmented auto vector last possible chance before Forth is started up User Manual V 1 Dec 11 2002 7 Table 1 Noted Memory Locations for Startup Hooks Name Value Notes quick_tag Ox3FFC store a tag quick vector Ox3FF8 CFA of word to call boot tag Ox3FFO store a tag boot vector Ox3FF4 CFA of word to call boot_start 0x10000 lower limit in flash for checking for an auto vector tag on a 1K boundary boot_end Ox1FFFF upper limit of flash for auto vector tag checking 1 A55A 2 A44A for first autostart or A55A for continuous last autostart 4 2 3 Tags The patterns OXA44A and OxA55A are referred to as tags and are used during the autoboot process to find vectors to be executed during the bootup process Only the lowest A44A and A554 tag will be executed with A44A going first This applies to the boot entry and autovectors The quick entry if used only uses A55A 4 2 4 Quick Entry Quick entry lets you get in on the boot process and set COP or any other write once registers before MaxForth starts up The tag contains a 32 bit value that is checked first and if present then the CFA stored at the vector preceding it is executed A55A 3FFC FL COP RUN CFA 3FF8 FL hook into quick entry vector 4 2 5 Boot Entry Boot entry lets you take over or execute something after MaxForth has been initialized This is a good time to modify the dictionary linkage to add extra words from flash The ve
35. compiler or assembler system that you have acquired separately to flash memory to be run The help menu invoked by typing a is To download to flash 1 bulk erase if necessary 2 Type f 3 Send S record with Xmodem or XModem 1K f Program flash b bulk erase all of the flash e erase application from flash type for help When programming the flash with an s record the locations to be programmed should be erased to OxFF first by either erasing the whole flash or just the part which contains the serial loader NV warnine Bulk Erase If you do bulk erase the entire flash with the b selection then the loader will be gone and you will not be able to reboot Your application should either put a vector at location 0000 or you should download the serial loader program xload21 14v2 s The serial loader works by running out of RAM At bootup the boot program in flash checks to see if there is an application at location 0x4000 by checking for a vector anything but OXFFFFFFFF If there isn t then it copies the serial loader program from flash to RAM and then runs the program The serial loader program must run out of RAM to be able to program flash memory If you erase all of flash then the next time you reset the board there will be no programs present and you will have to program it through the ONCE port Otherwise if you download a program with a reset vector at location 0x00000000 such as the serial loader program then
36. cted and controlled via PAO Set it high to disable and low to enable the receivers J16 is only needed when U2 the RS 232 chip is not installed and the LCD application required Do not connect J16 if U2 is present This can damage U2 User Manual V 1 Dec 11 2002 9 6 0 Board Layout 1 70 1 92 1 90 1 88 2 00 0 S e s e co OND gt dvo x Nn Ji 00 veut x se m 25 x cQ io ON c lee g esses MC7805 LM39d8if 9 sie e e228 8 6 08 S 2 e g eem ZOV2 NIWN laa Ea cc eee PLZ e dd ee WOQ SONOIAM3N MMM 0o He e 09 0 n mX iO O 2 e e ix ee 9 mo mae el Y Lo F4 5 5 zool js m B iue elwo
37. ctor follows the tag A44A 3FFO FL STARTUP CFA 3FF4 FL hook into boot start vector 4 2 6 Auto Vector As well at any 1K boundary in RAM you can lay down a tag followed by a vector A44A 1F800 FL STARTUP CFA 1F804 FL hook into auto start vector 4 3 On board Development System Taking advantage of the interactive nature of the board s development system MaxForth you can interact directly with the microcontroller s peripherals by fetching and storing values to the memory mapped configuration registers for the peripheral devices This is an effective way of understanding the peripheral documentation verifying correct initialization sequences running some tests on different configurations and debugging driver code as you develop it By typing in new definitions you can add new macros to the dictionary for interactive use or for creating an automated program Some examples are given later on 5 0 I O Connections and Jumpers The I O connections J1 J16 are highlighted with colored boxes on the board layout on page 10 A description of their function follows J1 LCD connector match the triangle on the connector with the pin with a square solder pad J2 J3 J4 are general purpose I O connectors including timers A D INT etc User Manual V 1 Dec 11 2002 8 J5 RESET amp GND pin not installed It may be used as option for a front panel mounted reset switch J6 Misc signals J7 JTAG Once J
38. e converting and finally reading and displaying the value Each of these boxes on the diagram will become a word except for Done HEX H a h COUNT 100 SWAP C8 OR DISPLAY READING 0280 H8 CHANNELO f CA0010 C 80 AND CLEARO CHANNELO IF 0010 DUP C 80 NOT AND SWAP C THEN REQUESTO CLEARO 21 CA000C C INIT A D 2 CA0200C CO CA0201 C 2 CA0202 C FF 0203 C GETAD INIT A D REQUESTO BEGIN CHANNELO UNTIL DISPLAY READING The first reading is from 5 volts the second from 0 volts and the third from 3 3 volts all applied to pin PQBO on connector J4 User Manual V 1 Dec 11 2002 12 GETAD 300 OK GETAD 21 OK GETAD 2A4 OK In theory 5 volts should be 3FF 0 volts should be 0 and 3 3 volts should be 2A3 So while the limits are not quite there the 3 3 volts is 8 2 Control Registers To control the CPU you need to read and modify the contents of the control registers Since the control registers are inside the CPU and not on the memory bus you will need to access them through assembler code The code below does this by using the mtcr and mfcr assembly instructions ored with a specified control register number MCore interface to internal registers Rob Chapman April 18 2002 HEX Assembly interface use mtcr and mfcr to transfer contents of control registers to and from memory CODE
39. e headers and the C code which is in RAM There is one word used to program and one word used to erase Only a 1K page of memory can be erased at a time In the 256K flash there are 256 pages Erasing leaves all the bits as FF Flash can be programmed 4 bytes at a time aligned to a 4 byte boundary To program the flash the location must be all FFs You must store the data into the variable d and the destination address for flash must be in a Once you set those two variables then you call PROGRAM WORD User Manual V 1 Dec 11 2002 24 Erasing is about as simple You must put the address of a location within the page into the variable a and then call ERASE PAGE Example Programming a word at 0x10000 HEX 10000 a ERASE PAGE erase 10000 103FF 12345678 d PROGRAM WORD store 32 bit data at location 10000 You can check by 10000 1 DUMP 8 5 Auto Install Program This example uses the previous programming tool for flash to store Forth programs in empty flash The program can be linked into the autostart system to initialize the dictionary and give a greeting There are two files involved AUTOBOOT F used to install a simple user program in flash that gets called at bootup UNBOOT2114 F this file can be used to remove all auto starting tags If you download the first file it will install the simple user program which will say Hello when restarted and add the word HI to the dict
40. ear out the boot flags in 3FF0 3FFC and any in Flash 3FF0 UNBOOT 3FFC UNBOOT 1FBFF 10000 DO UNBOOT 400 LOOP UNBOOTS 8 6 Advanced Programming This loader file which is written in Forth runs on top of MaxForth and allows you to mix S Records and Forth programming in the same file This is useful if you want to program exception vectors in C or User Manual V 1 Dec 11 2002 27 assembler and then debug them with Forth S records of SO S1 S2 S3 S7 S8 and S9 formats are accepted For an S7 S8 or S9 record the vector of the start program will be run at the time the line is downloaded This can be used to initialize the program add words to the dictionary or to runa sequence The file SRECBOOT F is installed on top of MaxForth and becomes a resident program in Flash which is called on MaxForth bootup The MaxForth prompt will be replaced with Boot V 3 The asterick will be displayed after each non blank line has been received and processed A line could be an s record or a line of Forth code If you type in Forth code it will not be echoed but it will execute You can test this by trying S If you want to get back to the Forth prompt just type in QUIT and hit enter Once you download the program and reboot the loader will be resident and running waiting for code to be downloaded You can remove the program at anytime by typing in AUTOBOOT and hitting the enter key 8 6 1 SRECBOOT F S Record loader
41. erminal or an equivalent setup You need to set it to 19200 BAUD one stop bit no parity and 8 data bits Connect an RS232 serial cable between your PC s COM port and the serial port on the board To power up the board you need a 9 to 12 volt plug in transformer plugged into the power jack PJ1 AC DC both polarities accepted When everything is ready and you plug in the power you should receive a prompt in the terminal program MMC2114 X Modem Flash Programmer V 2 or Max FORTH V5 1B license agreement is required And when you depress the ENTER key it should respond with type for help or OK Max FORTH prompt When you see that message it means the communication is established and you are ready to interact with the board and microcontroller By pressing the reset button SW1 you should get the same boot prompt as when you powered it up Pressing the reset button will leave the contents of most of the RAM intact which might be useful for debugging purposes whereas if you power cycle the board then all RAM contents will be lost User Manual V 1 Dec 11 2002 4 3 0 Memory Map The memory map consists of the RAM ROM and registers The interrupt vectors can exist anywhere by setting the vector base register VBR Figure 5 on page 15 OxFFFF FFFF 0x8000 0000 External Memory Registers Serial Loader or MaxForth 80 7FFF ports 0x00C0 0000 free space 0x0080 7FFF a Internal 80 0030 0x0080 0000 R
42. f you try to use the stack pointer it won t point to anything unless it has been initialized User Manual V 1 Dec 11 2002 16 8 3 2 Setting up the Interrupt Controller The interrupt controller is setup by modifying its memory mapped registers Address Bits 31 24 Bits 23 16 Bits 15 8 Bits 7 0 0x00c5_0000 Interrupt control register ICR Interrupt status register ISR 0x00c5_0004 Interrupt force register high IFRH 0x00c5_0008 lInterrupt force register low IFRL 0x00c5_000c Interrupt pending register IPR 0x00c5_0010 Normal interrupt enable register NIER 0x00c5_0014 Normal interrupt pending register NIPR 0 00 5_0018 Fast interrupt enable register FIER 0x00c5 001c Fast interrupt pending register FIPR 0x00c5 0020 through Unimplemented 0x00c5_003c Priority level select registers PLSRO PLSR39 0x00c5 0040 PLSR1 PLSR2 PLSR3 0 00 5 0044 PLSR7 0x00c5 004c PLSR12 PLSR13 PLSR14 PLSR15 0x00c5_0050 PLSR16 PLSR19 0x00c5_005c PLSR28 PLSR29 PLSR30 PLSR31 0x00c5_0060 PLSR32 PLSR33 PLSR34 PLSR35 0x00c5_0064 PLSR36 PLSR37 PLSR38 PLSR39 0x00c5_0068 through Unimplemented 0x00c5_007c Figure 7 These registers are mapped into the memory space and can be accessed to set up the interrupt controller peripheral for interrupt processing 2 access to the regions that are not implemented result in cycle termination errors Setting up the interrupt controller and peripheral is a matter o
43. f translating documentation into which register bits to twiddle and since these are all memory mapped you can access them from Forth Fora single interrupt to happen we need to set NIER For our purpose we have only one interrupt so we will not set its priority and leave it at 0 This means that we need to enable interrupts for priority level 0 HEX C50000 CONSTANT ICR interrupt control register C50002 CONSTANT ISR interrupt status register C50004 CONSTANT IFRH interrupt force register high C50008 CONSTANT IFRL interrupt force register low C5000C CONSTANT IPR interrupt pending register C50010 CONSTANT NIER normal interrupt enable register User Manual V 1 Dec 11 2002 17 C50014 CONSTANT NIPR normal interrupt pending register C50018 CONSTANT FIER fast interrupt enable register C5001C CONSTANT FIPR fast interrupt pending register C50040 CONSTANT PLSR base of priority level select registers 0 39 1 NIER For debugging you can just fake interrupts using the interrupt controller force interrupt registers The interrupt provides a way to create an interrupt for testing just by writing to a register Since there are 40 possible interrupt sources from all the peripherals two 32 bit registers are used to provide this IFRH and IFRL By setting a bit in these registers you can force that interrupt from that peripheral to happen In the interrupt service routine
44. igned int Integer for signed numbers typedef unsigned int Natural for unsigned numbers including 0 typedef void inner void inner interpreter define Forth void typedef void Forth void Forth word define Literal define Forward A define Backward A Literal A signed sizeof Forth const Cell A Literal A sizeof Forth define String S S define CONSTANT S Forth const S Forth Forth Literal define FUN_VECT void void good for casting vector adddresses should be in micro h user dictionary size define UD_SIZE 1000 User Manual V 1 Dec 11 2002 37 flag ifndef TRUE define TRUE Cell 1 define FALSI fendif ul e list Forth functions to be called extern inner wp ip extern Cell dsp rsp data stack pointer and return stack pointer extern void iboot void extern const Forth tasknfa extern const struct unsigned char name 6 const unsigned char link void pfaptr tasknfa should have a limit as well maybe just documented or known extern Forth const task virtual forth engine definitions typedef struct void inner void code void points to code like the inner interpreter Quarkextra typedef inner Quark fundamental building block typedef union param void inner void points
45. ilities timers MMC2114 Microcontroller interrupts Figure 1 Peripheral interfaces on the 2114 microcontroller 1 1 Noted microcontroller features MCORE 32 bit RISC low power integer processor 256K of word programmable flash memory 32K of static RAM 8channels of 10 bit A D with queueing 2 asynchronous serial channels 1 synchronous serial channel 8 timer channels with PWM capability up to 40 interrupts periodic interval timer watchdog timer 35 digital I O pins eight external interrupts ONCE debug support The computer board s power consumption with RS 422 drivers installed is about 80mA 1 2 Included Files The following files are included and are available from our website The MaxForth file is only available if you have licensed it nmin2114v1 pdf this manual in PDF format xload21 14v2 s serial loader file in s record format that can be downloaded through the ONCE port or serial port mfcoreapp51b s MaxForth in s record format srecboot f s record loader and Forth loader which loads application programs into RAM or Flash autoboot f simple tool set for creating autostarting programs in flash User Manual V 1 Dec 11 2002 3 unboot2114 f for removing auto start tags 2 0 Getting Started Computer Power Serial Cable You will interact with your board by connecting it to a PC using a serial cable and running a terminal program such as HyperT
46. ionary If you download the UNBOOT 21 14 F file it will cancel the autoboot feature from the simple user program 8 5 1 AUTOBOOT F Application tools Rob Chapman Aug 7 2002 put Forth application into Flash and allow hooking into autoboot COLD HEX firstword dictionary sentry Flash interface written in C and compiled to an srecord flash2114 c VARIABLE a where to put flash address VARIABLE d where to put flash data VARIABLE err where error codes are stored 1 5 or 0 21C CONSTANT CLOCK D00002 CONSTANT SGFMCLKD DECIMAL INIT FLASH initialize the flash CLKD register CLOCK 200000 DUP 60 gt IF 8 64 THEN SGFMCLKD C INIT FLASH run so flash can be programmed HEX HERE program a 32 bit word with d at a 24709E00 743E6007 9704773D 83072D17 16373ED7 60121225 1B7501F5 01657639 C7061657 D706C706 C6061657 0 76 802 9204FOlF 75358705 37F7E0 60279704 F0187732 87079703 76328706 2D8E35FE 16E735D7 970687 35F79705 870537F7 E0041256 870637F7 EFFD7627 870637E7 EFFD8E 207000CF w Oo HERE erase a page containing a 74216007 97047621 C7062E17 D706C706 C6062E17 OF76E803 60379704 OOCF751C 870535C7 97058705 35D79705 77178607 77198707 97067618 User Manual V 1 Dec 11 2002 25 87062D83 35F316 37F7
47. ke header s cii make it as a constant void dp m point to C variable makewords h define VARIABLE A make_variable A amp A define FUNCTION A make_header A amp A void make_header Byte void void 1 Byte void User Manual V 1 Dec 11 2002 41
48. l registers with their labels and values This is the output from running CREGS CREGS 0 80000000 PSR 1 0 VBR 2 4984 EPSR 3 1DA83004 FPSR 4 8540380 EPC 5 4441280 FPC 6 28004023 SSO 7 8 9 C 220002C0 551 41406000 SS2 C26620 SS3 8200444 SS4 0 GCR 0 GSR 8 3 Implementing an Interrupt The 2114 contains a lot of parts to get right usually all of them before you can make an interrupt more generally referred to as an exception happen You must set up the CPU the interrupt controller and an interrupt source such as a peripheral Setting up the CPU involves modifying CPU control registers while setting up the interrupt controller and peripheral involves modifying their memory mapped control registers The interrupt machinery on the 2114 supports a wide range of operational capabilities You can just use one interrupt or support a complex system of prioritized interrupts from all peripherals Interrupts can even be forced to happen to provide for a way of testing or syncing To set up an interrupt you d f ollow these steps 1 setup VBR and PSR EE IE 2 setup vector for interrupt routine User Manual V 1 Dec 11 2002 14 3 set up interrupt controller NIER 4 setup peripheral 8 3 1 Setting up the CPU Setting up the CPU is a little harder because you need to access its internal registers PSR and VBR which can only be done in assembler 90 29 8B 7 036 5 04 3 2 A 20 19 17
49. n Cell sample no xtern Byte samples extern void sir pit void extern void sir spi void void hello void ind void _start void link these C words to the Forth dictionary FUNCTION hello VARIABLE ind VARIABLE samples VARIABLE sample_no VARIABLE sir spi VARIABLE sir pit 8 6 11 makewords c Add to dictionary from C Rob Chapman Nov 20 02 include lt string h gt include forth h include makeword h define list void 0x800508 points to last in dictionary define dp Byte 0x80050C dictionary pointer User Manual V 1 Dec 11 2002 40 define cii inner 0x4888 constant inner interpreter void make_header char s void m link word to dictionary Byte 1 strlen s get length void t list get current nfa xlist void dp set list to new word 1 0x80 store count byte with msbit set while 1 for the length of the string dp 5 create the name dp 1 0x80 terminal byte while Cell dp amp sizeof Cell 1 alignment dp 0 zero and increment void t add link to current word void dp void dp 2 sizeof Cell pfa pointer dp sizeof Cell next cell void dp point to C routine void make_variable char s void m link as variable constant ma
50. or table in the upper 1K of the 32K internal RAM so the normal and fast interrupt vectors need to be placed at vectors 10 11 or 807C00 28 and 807C00 2C User Manual V 1 Dec 11 2002 15 Vector Vector Number s Offset Hex Assignment 0 000 Reset Misaligned access Access error Divide by zero 010 Illegal instruction Privilege violation 01C Breakpoint exception 020 Unrecoverable error om j N NNNM NEM 7 10 INT autovector 11 FINT Autovector 12 Hardware accelerator 13 14 Reserved 15 03C 16 19 040 04C TRAP 0 3 instruction vectors 32 127 080 1FC Reserved for vectored interrupt controller use Figure 6 The exception vector table pointed to by VBR The 40 peripheral interrupts on the 2114 can be vectored to the 32 127 vectors or just through the normal and fast vectors Your servicing interrupt routine must be in assembler and the vector that you place in the table must point to the start of the code You must push registers if you are to use the same register file as normal processing and your routine must end with an rte instruction NOTE Alternate register file If you want to use the alternate file of registers AF for an interrupt make sure you have the least significant bit in your interrupt vector set The CPU masks off the lower two bits but also records the Isb into the AF bit enabling the alternate register file RO 15 Be careful though i
51. rface Create an opcode with the given control register and then s tore it in the code word before running it CRN control register contents return contents of control reg 10 74021003 OR MFCR gt R RQ FCR R gt C CRN value control register store value into control reg 10 73021803 OR MICR gt R Re R gt 8 MICR CREATE MNEMS 13 4 pointers to 13 mnemonics HERE SWAP 4 MNEMS 22 WORD C8 1 ALLOT ALIG SPR SPR ABS 1 DUP HERE SWAP NOT AND DP 0 PSR 1 VBR 2 EPSR 3 M FPSR 4 M EPC 5 FPC 6M 550 User Manual V 1 Dec 11 2002 32 7 M 551 8 552 9 553 554 B M GCR C M GSR ALIGN Dump all the control registers CREGS CR DODO I2 R I CRN 9 U R I 4 MNEMS COUNT SPACE TYPE CR LOOP Vector table for interrupts 803C00 CONSTANT VECTORS out of the way on a 1K boundary C50010 CONSTANT NIER normal interrupt enable register C50045 CONSTANT PLSR5 C5005E CONSTANT PLSR30 C50000 CONSTANT ICR MCORE constants for registers CB0000 CONSTANT CB0001 CONSTANT CR2 CB0002 CONSTANT BR CB0003 CONSTANT SR CB0005 CONSTANT DR CB0006 CONSTANT PURD CB0007 CONSTAI PORTS CB0008 CONSTANT DDRS C5000C CONSTANT IPR SLAVE 0 DDRS C
52. s VARIABLE d where to put flash data VARIABLE err where error codes are stored 1 5 or 0 21C CONSTANT CLOCK D00002 CONSTANT SGFMCLKD DECIMAL INIT FLASH initialize the flash CLKD register CLOCK 200000 DUP 60 gt IF 8 64 THEN SGFMCLKD C INIT FLASH HEX HERE program a 32 bit word with d at a 24709E00 743E6007 9704773D 83072D17 16373ED7 60121225 1B7501F5 01657639 C7061657 D706C706 C6061657 0F76E802 9204FO0lF 75358705 37F7E003 60279704 F0187732 87079703 76328706 2D8E35FE 16E735D7 97068705 35F79705 870537F7 E0041256 870637F7 EFFD7627 870637E7 EFFD8E00 207000CF HERE erase a page containing a 74216007 97047621 C7062E17 D706C706 6062 17 OF76E803 60379704 O0CF751C 870535C7 97058705 35D79705 77178607 77198707 97067618 87062D83 35F31637 35E79706 870535F7 97058705 37F7E004 12568706 37F7EFFD 760E8706 37E7EFFD 760C8706 3FC72E17 2A17E003 60479704 00 8706 3FD72E17 2A17E002 60579704 OOCF0000 err a 00D00010 00D0001C 00000020 CODE ERASE PAGE END CODE LATEST PFAPTR CFA connect to the C routines CODE PROGRAM WORD END CODE LATEST PFAPTR CFA This program consists of two parts the part in the Forth user dictionary th
53. v 21 2002 include mmc2114 h SGFM Commands User Mode define ERASE_VERIFY 0x05 define PROGRAM WORD 0x20 define PAGE ERASFE 0x40 define MASS ERASE 0x41 define FLASH START x00000000 define FLASH END Ox0003FFFF define FLASH SIZE 0x00040000 x00020000 128k banks x00002000 8k sectors minimum protectable area define BANK SIZE define SECTOR SIZE C C define BANKO define BANK1 x00 x01 D INT32U d a err global accessable data and address void program void program a word INT16U protect mask err 0 protect mask 1 lt lt a FLASH START amp BANK SIZE 1 SECTOR SIZE reg SGFMPROT reg reg SGFMPROT reg amp protect mask clear the protects for the bank if reg_SGFMPROT reg reg_SGFMPROT reg amp protect_mask make sure that the protect got cleared not locked err 1 return if reg SGFMUSTAT bit CBEIF 0 make sure a command isn t active err 2 User Manual V 1 Dec 11 2002 22 return volatile INT32U a d write the value to the address provided reg SGFMCMD bit CMD PROGRAM WORD write to the command buffer reg SGFMUSTAT bit CBEIF 1 clear CBEIF flag by writing wait for the command to c while reg SGFMUSTAT bit CB while reg SGFMUSTAT bit CC void erase void erase a pa
Download Pdf Manuals
Related Search
Related Contents
NuVent NXBV70 Instructions / Assembly Samsung GT-C3212 Vartotojo vadovas EA840DA-1(リモートスイッチ)取扱説明書 LES GANGS DE MOTARDS CRIMINALISES Guide du langage juridique Vocabulaire, pièges et USER`S MANUAL - New Look Time CIMCO Edit v6 Vuolas Electronics Oy Ltd. Copyright © All rights reserved.
Failed to retrieve file