PDA

View Full Version : Technical Support on HC12 Forth


administrator
02-18-00, 10:06 AM
You can find a FORTH library at the following address:<br>http://www.ee.ualberta.ca/~rchapman/MFwebsite/V50/Alphabetical/Brief/index.html

MLCarter
06-11-00, 12:06 AM
I'm using a NMIT -0020 to control a RAPS<br>power system. Everything is in RAM I would<br>like to move the prog to an external eeprom<br>and have it boot up from there after power<br>up. Can you help me. I can get words on with<br>EEWORD and EEMOVE but how do you restore dictionary pointers ?

nmitech
06-12-00, 11:28 AM
Here is the sample program for the autostart<br>( APPLICATIONS: - external eeprom autostart.<br>( - variables stay in ram<br>( - link all new words on power up.<br>( HARDWARE CONFIGS:<br>( - eeprom jumpers from 8000 - 9FFF, 8k-byte<br>( - ram jumpers from 0000 - 1FFF, 8k-byte<p><br>HEX<p>0 8000 EEC! ( kill previous autostart if present<p>COLD <p>HEX<p><br>8080 30 ! ( assume eeprom is available at $8000, U3 socket<p>( assume ram is installed on U2 socket )<br>0200 CONSTANT RAM EEWORD 0202 RAM !<p>: RAM-VARIABLE RAM @ CONSTANT 2 RAM +! ; EEWORD <p>: 2RAM-VARIABLE RAM @ CONSTANT 4 RAM +! ; EEWORD<p>RAM-VARIABLE NUM1 EEWORD ( 16-bit variable<br>RAM-VARIABLE NUM2 EEWORD ( 16-bit variable<br>2RAM-VARIABLE NUM3 EEWORD ( 32-bit variable<br>( ... more variables here if you wish <p>: INIT-VARIABLES<br> 0 NUM1 !<br> 0 NUM2 !<br> 0 NUM3 2!<br>; EEWORD<p>: NUM1++ NUM1 1+! ; EEWORD<p>: NUM2++ NUM2 1+! ; EEWORD<p>: PRODUCT NUM1 @ NUM2 @ UM* NUM3 2! ; EEWORD<p>: DELAY 2000 0 DO LOOP ; EEWORD<p>: MAIN<br> 8004 6 6A CMOVE ( move all new words to UAREA internal ram on power up )<br> INIT-VARIABLES<br> CR .&quot; TO QUIT, HIT ANY KEY &quot;<br> BEGIN<br> DECIMAL<br> CR NUM1 @ U.<br> .&quot; x &quot; NUM2 @ U.<br> .&quot; = &quot; PRODUCT NUM3 2@ D.<br> DELAY<br> NUM1++<br> NUM2++<br> ?TERMINAL UNTIL<br> ABORT<br>; EEWORD<p>(save new words in the eeprom so that you can link it back on power up <br>6 8004 6A EEMOVE<p>161 DP ! ( put DP back in ram so it won't get lock up in eeprom<br>1F0 AUTOSTART MAIN (just create an autostart pattern in ram,<br>1F0 8000 4 EEMOVE ( then copy it into eeprom<p>( now recycle the power or reset, it will auto start your program )<p>

kevinr
07-11-00, 10:19 PM
Does anyone have an I/O definitions file? <br>I would like to know what the addresses of the ports are. I have a memory map but it doesn't include enough detail. Are things based at $B000 on the 68HC12 as they are on the 68HC11. I've got that def file to work from but nothing seems to work.

kevinr
07-11-00, 11:03 PM
Could some one give me an example file in Forth or in assembler to output something to Port A on the NMI0912 board? I can write this code on my evaluation board but I can't figure out the memory map I've got for the NMI0912 running MaxForth. If I clear the RAM I kill Forth. Where are the I/O registers redirected in memory so they're available for me to manipulate?

kevinr
07-11-00, 11:31 PM
After many hours of frustration I finally got something to work. PORTA maps to $0000, DDRA maps to $0002. I was successful in getting an LED to turn on and off. It just took trying all possible combinations and writing code to test all of the locations between 0000 and FFFF to see what is changeble. After that it was just a matter of time. I wish this was documented somewhere but I should consider myself lucky for getting it to work. HOORAY!!!

rob
07-11-00, 11:38 PM
This manual is quite large but all the information you require is available in here:<br>http://ebus.mot-sps.com/brdata/PDFDB/MICROCONTROLLERS/16_BIT/M951446360206collateral.pdf<br>Other documents are available at:<br>http://ebus.mot-sps.com/ProdCat/psp/0,1250,68HC912B32~M98637,00.html<br>The register block is mapped to the lowest 256 bytes of memory starting at 0000 at reset and Forth doesn't do any remapping. You found out the hard way.<p>Rob

rob
07-11-00, 11:41 PM
Here's a couple of tools for saving to Flash. The first tool is an<br> easy and automatic way of saving your words to flash. The second<br> tool is used to save linkages and provide autostart. Mix and match<br> these tools to find an optimum solution for you. I've blended them<br> to work together reasonably well but they can still run into each<br> other so use caution. And feel free to modify and tinker but keep<br> one hand on the control-G button and on hand on the serial boot<br> jumper.<p> You could use the second tool all by itself but it'll leave all<br> code in RAM and if you are RAM limited then that is not so good.<p> Rob<p>( Tool1: Automatically ROMs all code into Flash )<br>HEX<br>( ==== Find empty space in Flash ROM ==== )<br>: FLBLANK ( -- a ) F800 F000 8000<br> DO FF I 10 OVER + SWAP DO I C@ AND LOOP FF = IF DROP I LEAVE THEN<br> 100 +LOOP DUP F800 = IF CR .&quot; Flash is full.&quot; CR ELSE DUP U. THEN ;<p>FLBLANK FDP ! FORGET FLBLANK<p>( ==== ROM it all with auto-rom words<br>: ; [COMPILE] ; FLWORD ; IMMEDIATE FLWORD<br>: CONSTANT CONSTANT FLWORD ;<br>: CREATE HERE CONSTANT ;<br>: VARIABLE CREATE 2 ALLOT ;<br>: FL! ( n \ a -- ) OVER &gt;&lt; OVER FLC! 1+ FLC! ; ( Fixed FL! )<p>( Tool2: Image saver and restorer for autobooting Rob Chapman Jul 11, 2000 )<p>( ==== Image and properties ==== )<br> HERE CONSTANT sys-end<br> R0 CONSTANT sys-start<br> sys-end sys-start - CONSTANT sys-size<p>( 0 Image components and offsets )<br>( + 0 A44A - just run and return<br>( + 2 RESTORE - must point to saved image of restore<br>( + 4 main startup word stored by INSTALL<br>( + 6 copy of RAM locations in system<br>( + 6 + sys-size length of image<br>( + 8 + sys-size image of code<br>HEX<br>( ==== Startup services ==== )<br>( ==== Find empty space in Flash ROM ==== )<br>: FLAUTO ( -- a ) 0 F000 FDP @ 3FF + FC00 AND<br> DO I @ FFFF = IF DROP I LEAVE THEN 400 +LOOP<br> DUP 0= IF CR .&quot; Flash is full.&quot; CR ELSE DUP U. THEN ;<p>FLAUTO CONSTANT FL-START ( start of flash: where to save to<br> sys-end CONSTANT RAM-START ( where to save from<p>: -AUTOSTART 0 FL-START FLC! ; ( turn off autostart flag )<br>: FL+ FL-START + ;<p>: RESTORE ( can't call nonexistant words so [ ] LITERAL is used<br> [ 6 FL+ ] LITERAL ( start of system image )<br> [ sys-start ] LITERAL ( start of system variables )<br> [ sys-size ] LITERAL CMOVE ( restore system RAM image<br> [ sys-size 8 + FL+ ] LITERAL ( start of dict image )<br> [ RAM-START ] LITERAL ( start of dict space      <br> [ sys-size 6 + FL+ ] LITERAL @ <br> ?DUP IF CMOVE ( restore dictionary image to RAM ) ELSE 2DROP THEN<br> [ 4 FL+ ] LITERAL @ EXECUTE ; ( run main program<p>: SAVE<br> A44A FL-START FL! ( fire once autostart flag for startup )<br> ['] RESTORE CFA 2 FL+ FL! ( restoration vector )<br> ['] TASK CFA 4 FL+ FL! ( null vector )<br> sys-start 6 FL+ sys-size FLMOVE ( save system variables )<br> RAM-START sys-size 8 + FL+ HERE RAM-START - ( src \ dst \ siz )<br> DUP sys-size 6 + FL+ FL! <br> ?DUP IF FLMOVE ( save length & dictionary ) ELSE 2DROP THEN ;<p>: INSTALL ( a -- ) SAVE CFA 4 FL+ FL! ;<p>In response to:<br>&gt;I have a very fundamental question regarding the user dictionary. I have a<br>&gt;68HC912 I am using in unexpanded mode with Maxforth Version 5.0L. Because<br>&gt;of limited ram and eeprom I want to use flash to save parts of my code. <br>&gt;<br>&gt;For instance :<br>&gt;<br>&gt;HEX<br>&gt;D6 CONSTANT PORT.S FLWORD<br>&gt;<br>&gt;This properly saves constant PORT.S, that is until I power down or do COLD.<br>&gt; How do I get my linkage back?<br>&gt;<br>&gt;I want to move about 1k of program out of eeprom and ram into the flash.<br>

rob
08-01-00, 05:00 AM
Here's an updated version of the two tools. Code is stored in Flash and the system variables are stored in EEPROM. Use this code at the beginning of the file and then to tie your startup word in, do:<br> ' startupword INSTALL<p>Your code can now be autorun from startup. This code can be recompiled many times before Flash memory fills up and will have to be initialized again by the serial loader.<p>COLD<p>( Tool1: Automatically ROMs all code into Flash )<br>HEX<br>( ==== Find empty space in Flash ROM ==== )<br>: FLBLANK ( -- a ) F800 F000 8000<br> DO FF I 10 OVER + SWAP DO I C@ AND LOOP FF = IF DROP I LEAVE THEN<br> 100 +LOOP DUP F800 = IF CR .&quot; Flash is full.&quot; CR ELSE DUP U. THEN ;<p>FLBLANK FDP ! FORGET FLBLANK ( find blank FLASH area )<p>( ==== ROM it all with auto-rom words<br>: ; [COMPILE] ; FLWORD ; IMMEDIATE FLWORD<br>: CONSTANT CONSTANT FLWORD ;<br>: CREATE HERE CONSTANT ;<br>: VARIABLE CREATE 2 ALLOT ;<br>: FL! ( n \ a -- ) OVER &gt;&lt; OVER FLC! 1+ FLC! ; ( Fixed FL! )<p>( Tool2: Image saver and restorer for autobooting )<br>HEX<br>( ==== Image and properties ==== )<br>( + 0 A44A - just run and return<br>( + 2 RESTORE - must point to saved image of restore<br>( + 4 main startup word stored by INSTALL<br>( + 6 copy of RAM locations in system<p>( ==== Initialized RAM space ==== )<br>( put variables here and they will always get initialized to the same value )<br>( variables after &quot;sys-end&quot; will not get initialized )<p>( ==== System boundaries ==== )<br>HERE CONSTANT sys-end ( end of system variables )<br> R0 CONSTANT sys-start ( first system variable )<p>sys-end sys-start - CONSTANT sys-size<p>( ==== Startup services ==== )<br> D00 CONSTANT ROM-START ( start of ROM: where to save to<br> ROM-START 6 + sys-size + EDP ! ( free space<p>: ROM+ ROM-START + ;<p>: RESTORE<br> 6 ROM+ ( start of system image )<br> sys-start ( start of system variables )<br> sys-size CMOVE ( restore system RAM image<br> 4 ROM+ @ EXECUTE ; ( run main program<p>: INSTALL ( tick -- ) ( Use: ' Main INSTALL<br> A44A ROM-START EE! ( fire once autostart flag for startup )<br> ['] RESTORE CFA 2 ROM+ EE! ( restoration vector )<br> CFA 4 ROM+ EE! ( main vector )<br> sys-start 6 ROM+ sys-size EEMOVE ; ( save system variables )<p>' TASK INSTALL<br>

tomscott
09-13-00, 10:01 AM
I'm trying to thread to KEVINR's post of 11:31 pm on 7.11.2000 but have not a clue on how to do this ! <br> Forth is supposed to be written such that one can easily find anything (even the startup code s/b written in F' ) to get answers such as where is the register block .<br> I was very impressed when the 1st Forths came out ( 40 years in Tucson, where Chuck wrote F' ) as i could do anything by disassembling that part of F' . If it's F' , then everything must be visible ( structured) . Now i'll contradict myself , as i'm going to write a shell for F' that makes F' intuitive to non proff' programmers (it will look like a pocket calculator language , as all micro's s/b ..... no more stupid assemblers except for occasional inline code ) .