View Full Version : EEWORD Question
g_jilek
02-13-03, 01:47 PM
I have a syntax question on how to call a word in FLASH.
I have not seen an example of this.
: ADC_INIT ( -- )
2000 0E80 !
0003 0E81 !
3210 0E83 !
7654 0E84 !
0002 0E85 !
; EEWORD
ADC_INIT EEWORD
Is this the proper way to code something like this?
Thanks
g_jilek
RMDumse
02-13-03, 02:08 PM
No, that syntax would cause you some problems.
The correct way is to follow each word as it is defined with the word EEWORD to move it from its construction point in RAM to be relinked and moved into FLASH.
So the first EEWORD just after the ";" moved it. The second one would try to move the next lowest word in RAM, maybe TASK, into Flash which would be a problem.
Only one EEWORD is used per definition. But one for every definition. Don't forget VARIABLE CONSTANT etc. are definitions.
nmitech
02-13-03, 02:15 PM
Do not include EEWORD after ADC_INIT when you call. Here is an example,
: ADC_INIT ( -- )
2000 0E80 !
0003 0E81 !
3210 0E83 !
7654 0E84 !
0002 0E85 !
; EEWORD
MACHINE ATOD EEWORD
ON-MACHINE ATOD
APPEND-STATE GET-ADC0 EEWORD
APPEND-STATE GET-ADC1 EEWORD
IN-STATE
GET-ADC0
CONDITION
TRUE
CAUSES
( read ADC0 and display data on screen )
ADC0 ANALOGIN 8 / U.
THEN-STATE
GET-ADC1
TO-HAPPEN
IN-EE
IN-STATE
GET-ADC1
CONDITION
TRUE
CAUSES
( read ADC1 and display data on screen )
ADC1 ANALOGIN 8 / U.
THEN-STATE
GET-ADC0
TO-HAPPEN
IN-EE
DECIMAL
: MAIN
ADC_INIT
GET-ADC0 SET-STATE
EVERY ???? CYCLES SCHEDULE-RUNS ATOD
; EEWORD
HEX 7C00 AUTOSTART MAIN
SAVE-RAM
RMDumse
02-13-03, 02:20 PM
Calling a word is no different when it is Flash than when it is in RAM. Just say its name. The only difference is where in the memory map it is located. The EEWORD does all the relinking necessary to move it. Well, of course there can be problems if the word did something like selfmodification, because what would write in RAM wouldn't write the same way in Flash. But by in large, you'd never know the difference between the words, unless you did a WORDS list to see where it was in memory.
g_jilek
02-13-03, 04:48 PM
When one is creating the AUTOSTART word is it necessary to include the defined words in the program or only the first definition, or is the first word called by the program?
Thanks for the help,
g_jilek
RMDumse
02-13-03, 05:08 PM
Generally you write your program like a pyramid, so finally there is one word that sets everything going. In the IsoMax(TM) paradigm of state machines, that could be the MACHINE-CHAIN. Or perhaps it is a startup word which sets all the states first then schedules the MACHINE-CHAIN. If you aren't using machines, then it will be a Forth word which contains and endless loop constantly doing what you want done over and over, with maybe a back door to escape for debugging purposes.
In any case, you autostart the top word, and everything needed under it is called. Now, all the words the top word will call down the pyramid need to be in memory. If you autostart a word that calls another word that is in RAM instead of FLASH, then after powering down and back up, you could have a problem because the lower word went away with the powerdown. Sometimes this can trick you, because it was there when you hit reset to test. That's not quite the same as a true power cycle. Hope that helps.
mohanarpit
02-08-08, 10:42 AM
I am trying to make a servo motor run GRADED using SERVOPOD USB .
the code is have written works perfectly when run through the machine :
DECIMAL
: LMO
5518 150 * /
4231 +
TB0 PWM-OUT
;
32625 TB0 PWM-PERIOD
TB0 ACTIVE-HIGH
but the moment i try to load it on the board using eeword like :
DECIMAL EEWORD
: LMO
5518 150 * /
4231 +
TB0 PWM-OUT
; EEWORD
32625 TB0 PWM-PERIOD EEWORD
TB0 ACTIVE-HIGH EEWORD
AUTOSTART LM0
SAVE-RAM
, IT HANGS THE MOMENT THE PWM-PERIOD LINE IS BEING TYPED
please provide solution to this problem and also provide code as to how to make the servo start moving as soon as the board is switched on ....
Arpit
mohanarpit
02-09-08, 09:16 AM
DECIMAL
: LM0 ( n -- )
5518 150 */
4231 +
TB0 PWM-OUT
;
35625 TB0 PWM-PERIOD
TB0 ACTIVE-HIGH
this program works perfectly well when run through the computer . but the moment i try to load it on servopod usb , like ,
DECIMAL EEWORD
: LM0 ( n -- )
5518 150 */
4231 +
TB0 PWM-OUT
; EEWORD
35625 TB0 PWM-PERIOD EEWORD
TB0 ACTIVE-HIGH EEWORD
the program loading hangs while the second last line 35625 TB0 PWM-PERIOD EEWORD is being loaded ....
plz provide a solution to this problem.
arpit
RMDumse
02-09-08, 12:48 PM
DECIMAL EEWORD
DECIMAL is executing immediately. It is not a definition. So when you put EEWORD behind it, something bad happens. You try to more a word already in Flash to Flash.
: LM0 ( n -- )
5518 150 */
4231 +
TB0 PWM-OUT
; EEWORD
Here LM0 is a definition, and it does need to be moved to Flash, so using EEWORD here is appropriate.
35625 TB0 PWM-PERIOD EEWORD
TB0 ACTIVE-HIGH EEWORD
But here again, the PWM-PERIOD is being executed immediately. There's no new definition there, so you are again commanding the last definition (something already in Flash) be moved in Flash. Same is true with ACTIVE-HIGH. It is being executed immediately. There's no additional definition being added to the dictionary, yet you are commanding the new definition be move. There is no new definition, so there are problems.
Here is a suggestion. Put your initialization inside a definition.
DECIMAL
: LMO
32625 TB0 PWM-PERIOD
TB0 ACTIVE-HIGH
5518 150 * /
4231 +
TB0 PWM-OUT
; EEWORD
( AUTOSTART LM0
SAVE-RAM
I don't think you want to autostart LM0 because it needs to be feed something on the stack as an initial parameter. I can see you might want to SAVE-RAM to keep it's linkage, but it doesn't look like a word that can be autostarted.
vBulletin v3.0.7, Copyright ©2000-2012, Jelsoft Enterprises Ltd.