From: Matthias T. <mt...@we...> - 2011-04-08 19:07:32
|
hi Hannu > > 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 I'll write one, asap. It's really a FAQ ... > > Q: How do I store the forth program to MCU so that when it starts I > don't need use serial port to upload it? A: Well This is same > question as previous. A forth program consists of words. You do not need to upload them repeatedly since they become part of the dictionay when they are defined. And the dictionary (just enter words to get the content) if kept across turn-off/turn-on/resets. You have two ways to start your program: interactivly by opening a terminal to your system and calling the start-word or you use the turnkey feature which does the autexec.bat job. Just keep in mind, that the command prompt itself is a started with the turnkey, you can effectivly disable any command prompt by overwriting the turnkey action. Unless for very well tested code, I prefer the interactive method. Overwriting turnkey is not difficult, but much harder to debug... > > Q: If my program get's into infinite loop is there any other way > except reset to return to prompt? A: Not really. The atmegas do not support any protection against errors. Amforth does not do so as well, simply for speed reasons. Any runtime checks slow down the system. Compile time checks cost code space which is usually never enough. And yes: its easy to corrupt the system and the only way to a get it up again is to re-flash it from the hex files. But thats done easily and does not hurt. IMHO. > > 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) The names of the registers are usually not available. Its of course possible to include them but this makes the dictionary much larger and usually only a few registers are used in normal programs. And again: code space is limited. If you really want to include the register names, you can define constants in your application master file (template.asm) just like .set WANT_PORTA = 1 .set WANT_PORTB = 1 etc The file core/devices/<controller>/device.asm has many of such variables. Just keep in mind: that WANT_something = 1 only makes the register names available. There is no code associated with. > > 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. Interrupts are .. difficult. I prefer implementing them in assembly, but one class of interrupts can be implemented in forth as well. details are in the technical handbook. > > Q: sleepmodes and multitasking? A: After reading technical manual > which is nice document I was left little uncertain about > multitasking. It is co-operative and pause causes context change. By > default pause was defined as nop? I'm interested this since I > noticed from archives that this was used to save power. Again: save code space but enable more advanced code structurs. The basic core does not do multitaskink, but provides the tools to implement it. Thats why pause is a noop by default, and thats clearly not a multitasker. Same with power saving. Not every application wants to save power, what you've read is more an outline how it could be done, not tested code. Maybe pito has some better ideas > > 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? Sure it can do so. Remember: amforth is 16bit, only numbers between -32000 und +32000 work trivially, others need more attention I just updated the FAQ section to demonstrate the interactive use. One example reads the return stack pointer from the atmega core, let me know if it helps you. > > Anyway all help is appreciated by this newbie forther. Just ask, It may take some time for the answer, but I'll do my best Matthias |