Hi Michael and rest of you! Thanks for kind answers. Those were very enlightning. I'll bring these new questions up so that beginners like myself doesn't need to ask them over again (if they can search archives) and maybe give some ideas what to put also getting started document. I have confidense that I can find the answers from examples and trying things. Even one fool can ask more questions than hundred wise men can answer, I hope you don't feel I'm abusing this list.
> > Am 08.04.2011 um 06:41 schrieb Hannu Vuolasaho: > >> Q: Is somewhere simple LED blinker example? >> A: saw examples directory and studying those programs. But the >> workflow from forth code to standalone program is missing > > \ example: > : main ( -- ) begin led-on 1000 ms led-off 1000 ms key? until ; > ' main is turnkey Just to make sure that I understood this correctly, we define main word which has loop and executes led-on word, puts 1000 to stack, waits one second turns led off waits and reads from serial port. The key? word puts true if there is input. Second line makes main executed with turnkey word which is like autoexec.bat :) I'm learning the language so I like to explain all code that I find so I understand what I read. > 1. flash amforth into device > 2. develop your forth code on the device. Since it is in flash, is > permanent. > 3. set turnkey, Since it is in eeprom its permanent too. > 4. turn off power of device. Turn power on, it will run your > application. wow. It's like a Commorode 64 or picoBasic. (PIC chip with interactive BASIC. Finnsh webpage only: www.picobasic.com) Anyway instant usable computer :) > > Step 2 can be very strenuous. amforth is very simple, it is for tiny > devices. I use gforth or some other "big" forth systems to develop > most of the forth code before it goes down the device and runs on > amforth. Since amforth is standard forth, this works nice. You have > to simulate features of the device. Fine tuning then is done > interactive on the device itself. So its kind of iteration using > gforth, test it in amforth on the device, continue this loop > modifying code until it does the job. MARKER word seems to be good for this. > > Usually it takes a lot of re-flashing amforth till everything is > works well. During flash everything is resetted. First are lost the forth words code and in EEPROM reset dictionary to them. So source file must be on computer where it van be uploaded to system. Also using ASM reguires reflashing. > Common constructs are: > : main ( -- ) begin ... key? until ; \ test for any key > : main ( -- ) begin ." ." 1000 ms key? dup if drop key $03 = then > until ; \ test ctrl-c OK. Now I don't understand. ." is for printing like ." Hello world!" If I've understood correct. What does two ." ." in row? wait a second check for input duplicate TOS (Why? does IF consume one?) and if is true drop TOS, retrive the character and read from memory address 03 ? Shouldn't that be just 03 when equality is tested and passed to until after then word. So My current understanding says that the duplicated key? is consumed only during until? >> Q: Register read and write? >> A: 1 PIN_NUMBER lshift REGISTER_NAME or! to set one bit. Are >> registers normally included? ( in C #include "avr/io.h" is needed) > > No. (as far as I know) Mathias trute wrote: >> Just keep in mind: that WANT_something = 1 only >> makes the register names available. There is no code associated >> with.Which wasn't clear to me. I believe PORTA is just address for I/O space >> where I want to write the the data. However most registers are 8-bit long. >> This will need some studying. > > > >> Q: How interrupts are used? >> A: First there has to be word for interrupt and it has to be told >> to sytem so that it knows what to run on interrupt and then >> registers are written to enable that interrupt. > > Religious content ;-) > > My opinion: Never use (highlevel) forth on a embedded device to serve > an interrupt. Use the method that comes with the device. On atmega: > place a jump to code fragment that will set a variable. If service > may be slow, serve that variable in your forth task later. True that. I need to check exsamples and study more. Right now I have questions in my mind. 1) Which registers I can use with ASM without pushing and popping them from stack. 2) How do I create variable so that for exsample ISR can increment counter and I can use it in forth. 3) How to add portions of ASM and specify words for it. > >> Q: Can Amforth used as calculator? >> A: Instead of using dc to calculate time to next coffee break forth >> prompt over serial cable could be used for that. Or can it? > > You will have to set up a real time clock in your device first I > guess, using a timer interrupt to count down the seconds, minutes, > hours. Well this question before I was sure how the system worked. I think I'll give amforth a try in my light dimmer. I can't wait for my new toy anymore. The geek factor is that dimming lights you can also make calculations with it. My nerd frineds are so jealous when they see that I can ask how much isĀ 2 5 + . I'm thinking something like two tasks. Two ASM helped interrupts. First is INT0 for sync and second is counter. First task fires triacs and second sleeps even there is no need for that and with some key drops to prompt so I can show off with the system in dimmed light :) There is no real need for sleeping in that project but maybe in some other project needs that and it is nice to learn things. Last of my questions is there way to see how some word has been defined? And last I like to share this idea. in avr-libc documentation there is a the simple demo project. It is interrupt driven and makes PWM. I think it could be nice if the demo project in getting starte page had first single task non-sleeping non interrupt version of the project and then shoved how to make as much as possible same project with interrupts. So far I think that amforth may become the default environment for my 8-bit AVR toys because forth as language thinks more like I do in principle. Learning curve is quite steep however since there are so many words and many look much a like and forth's postfix is sometimes hard to understand. But now I think I'll stop writing mail and start trying on that dimmer what I know about forth. ATMega88 is the victim this time. Best regards, Hannu Vuolasaho ------------------------------------------------------------------------------ Xperia(TM) PLAY It's a major breakthrough. An authentic gaming smartphone on the nation's most reliable network. And it wants your games. http://p.sf.net/sfu/verizon-sfdev _______________________________________________ Amforth-devel mailing list Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel