If anyone is interested: I've tested all digital input/output and the ADC and everything works. The only glitch was that the pins for UART1 were configured for serial communication. Next step was to test TWI/I2C and this does not work. I've compared the 328p and the 1248p and they are the same. Even different AI-chats (they sometimes have a hard time with Forth, but thats ok with me :) ) agree with me, it should work. When I inspect a simple i2c.ping with a logic analyzer the CLK-signal generates...
Well, I did just want to run the comparable benchmark. I mean to compare with the original benchmark code. The STM8 benchmark code, seems to be comparable to the first FF code.
Well, I did just want to run the comparable benchmark,
With for..next and u/mod the test runs in 1.7 seconds. Yes the same code above. And with 16 Mhz. There is no mod word in dictionary in FF5. correction : it is not same code. 1.7 secs for the code in that article with u/mod drop.
I see now. But why you try to show FF slower by changing the bench code. If you look to comments in that article, the guy (who promotes his STM8EF or stm8 eforth) says that his eforth for stm8 is faster than FF but not in reality.
: bench ( n -- ) dup for r@ dup for dup r@ gcd drop next drop next drop ; ok this is 1.7 secs the original test in that article
I am using a 16 Mhz Arduino Uno. Note that the bench word has been modified to run gcd 40000 times during the test.
Here, you wrote 1.7 secs. which is correct if I remember correctly :)
I am using a 16 Mhz Arduino Uno. Note that the bench word has been modified to run 40000 times during the test.
It looks like the full swing oscillator did the trick. I thought i had tried that but obviously not... Big thanks for the time you've invested in this!
I think here, you used 8 Mhz. Because I see 1.7 secs with 16 Mhz with this code.And mod word is not in dictionary of FF5, there is u/mod. Regards, my blog : erolcum.blogspot.com
With for..next and u/mod the test runs in 1.7 seconds. Yes the same code above. And with 16 Mhz
This code runs in 3898 milliseconds. Replacing u/mod drop with mod runs in 8440 milliseconds. : gcd ( a b -- gcd ) begin dup while swap over u/mod drop repeat drop ; : bench ( n -- ) ticks swap dup for r@ over for dup r@ gcd drop next drop next drop ticks swap - cr . ; 200 bench 3898 ok<#,ram>
Sorry for the late answer. I did not notice your message in the moderation queue until now. What code did you run ? With for..next and u/mod the test runs in 1.7 seconds. With for..next and mod the test runs in 3.8 seconds With do..loop and mod the test runs in 8 seconds. Same as Amforth. The word MOD is slow. It is defined using /MOD and SM/REM that then uses UM/MOD that is the basic division routine. In addition the original for..next code on that website only runs half as many iterations as the...
Sorry for the late answer. I did not notice your message in the moderation queue until now. What code did you run ? With for..next and u/mod the test runs in 1.7 seconds. With for..next and mod the test runs in 3.8 seconds With do..loop and mod the test runs in 8 seconds. Same as Amforth. The word MOD is slow. It is defined using /MOD and SM/REM that then uses UM/MOD that is the basic division routine.
Hello Mikael, You make a great job, firstly. You may know the answer possibly for my following question. There is a blog page written 10 years ago, and author says he measured 4 seconds for "200 bench" test (atmega328). But I measured 1.7 seconds with FF5.0. What may be the reason ? It's speed increased twice in 10 years ? https://weblambdazero.blogspot.com/2016/10/go-forth-with-arduino.html Regards, Erol
You could try with LOW:0xf7 to use the full swing oscillator that has more gain. This could be a solution if the crystal is just marginally working in the low power mode(LOW:0xff).
You could try with EXT:0x04. That activates the brown-out reset at 4.3 volts. It prevents the chip to run at too low voltages.
If it sometimes works, I would say you have a hardware problem. Maybe some intermittent connections on the breadboard. Poor decoupling etc, Is the clock reliable ? 16MHz? Check the clock with an oscilloscope. Does the FTDI supply enough current ? Are there voltage dips on the 5 volt. Does USB supply enough current? Are there other devices on the same USB bus? Front side USB connectors can be current limited by the computer internal wiring. I had that problem one time. The USB connectors or the cable...
I've done some more testing and have "reliable" boot after reset with "E FlashForth 5 ATmega1284 05.03.2026" displaying each time. Here's an example of output with a few key press from me: FlashForth 5 ATmega1284p 05.03.2026 � ? ok<#,ram> after that it is non responsive I got it to work TWO TIMES and tried "words" and a few calculations, all working perfectly. Electrically the chip sits on a breadboard with decoupled +5V from the FTDI. As I said before the setup works with a 328p. Fuses are: LOW:...
I use UART0 (pins 14=RXD0, 15=TXD0). I also use the "same" breadboard setup (obviously with shifted pins) for an 328p and it works. I will check all connections (for the umpht time) later today.
Could it be something simple like the UART line not being connected? In the simulator the UART RX configs and interrupt vectors look right. Are you using UART0 ? I also think the same fuses as the 328P should work.
Hello and thank you for your time! It sort of works, it boots with the message: E FlashForth 5 ATmega1284p 05.03.2026 But then it stops. I've tried several methods of programming the chip (TL866II+ ZIF and ICSP) and avrdude through an usbasp. The latter feels more robust. I've also tried to power it with both external 5V and with the FTDI adapter. The only thing I can think of is the fuses. I've (sort of) read the documentation and concluded it should be the same as the 328p. As this is only an hobby...
Hi, You need to install MPLABX V6.20 and XC8 V3.10. These are the versions I am using. Then create a project with ff-xc8.asm as source file. I will update the code to compile with the Atmega1284 and related CPUs. Obviously I cannot test since I do not have the hardware.
Hi, You need to install MPLABX V6.20 and XC8 V3.10. These are the versions I am using. Then create a project with ff-xc8.asm as source file. I will update the code to compile with the Atmega1284 and related CPUs. Obviously I cannot test since I do not have the hardware. Probably it could work since the related Atmega644 is already included.
Wow, you're really fast!
So now there is support for 1284 and 1284P. Also many others seem to compile and run in the MPLABX símulator. There are also ready made HEX files for 1284 and 1284P. These are not tested on real hardware. Don't hesitate to ask in case of problems.
ATMEGA: ATmega 1284P, better support for more processors
Hi, You need to install MPLABX V6.20 and XC8 V3.10. These are the versions I am using. Then create a project ff-xc8.asm as source file. I will update the code to compile with the Atmega1284 and related CPUs. Obviously I cannot test since I do not have the hardware. Probably it could work since the related Atmega644 is already included.
I think you mention about Mikael's github : https://github.com/oh2aun/flashforth/tree/master/avr/FF-ATMEGA.X But every chip has different specs or peripherals, I think it is not an easy step as you think. He can answer your question if he wants
Hello! Is there any documentation for how to compile for the Atmega 1284p? I've found one in my component storage and it would be nice to test this chip. I'm used to electronics and programming but I have no experience with compiling for Atmega processors (and quite rusty when it comes to assembler)
Added back the stack underflow detection. It got lost when I updated the code from AVRASM2 to XC8 compiler.
ATMEGA: Add stack underflow check
PIC18: BLOCK EDIT CORE
Had to revert INTERPRET and re-introduce ABORT for unknown words. It did not work like I was thinking with blocks. Also blocks24.fs was updated to work. There is a new word EXECUTE? to prevent potentially unknown words from aborting the evaluation of a block. execute? -mark marker -mark
PIC24: Revert to use ABORT in INTERPRET. Fixed BLOCK words
PIC18: put back ABORT for unkown words
PIC18: BLOCK EDIT
PIC18: Remove DO LOOP
PIC18:Remove P from PAUSE
PIC18: move words to root vocabulary
PIC18: Remove flow control and cpuload
PIC18: Remove flow control and cpuload
PIC18: FORGET HUH? assembler
PIC18: MARKER TINIT
PIC18: H.N, tasks MARKER
PIC18: Dot words, remove P words
PIC18: first 'working' version
PIC18: Abandon buggy xtended instruction set
PIC24: H.N SPACES
PIC18: ff-pic18.S
PIC18: rename ff-pic18.S
PIC18: rename directory
PIC18: updates
PIC24: forth files
PIC24: config files
Did some updates to the PIC24 part. - Less writes to flash on chips that do not have eeprom (almost all chips). A smarter algorithm compares the highest written flash address with the xt to be executed. - DOES> fixed to work also with an empty DOES> part. - Unknown words do not cause INTERPRET to ABORT. This allows that unknown (marker words) words do not abort the loading from blocks or from Pere's file system. This was needed to let MARKER words to be used in those scenarios. - 64 by 64-bit unsigned...
PIC24:Less flash writes,UQ/,fix DOES>
PIC24: improved flash write algorithm
PIC24: PIC24F32KA302
PIC24: PIC24F32KA302
PIC24: dsPIC33FJ128GP802 alpha
PIC24: dsPIC33FJ128GP802 alpha
PIC24: dsPIC33FJ128GP802 alpha
PIC24: dsPIC33FJ128GP802 alpha
PIC24: dsPIC33FJ128GP802 alpha
PIC24: dsPIC33FJ128GP802 alpha
PIC24: dsPIC33FJ128GP802 alpha
PIC24: dsPIC33FJ128GP802 alpha
PIC24: dsPIC33FJ128GP802 alpha
FF6: PIC24 initial
thanks for the information. but yes, i'm using scamp words. but because i'm using the FSM with vocabularies, really is not necessary use the marker option. I keep the specific words in different vocabularies.and i load them only when necessary.
I actually found a simple solution to change INTERPRET to continue interpreting when a error is encountered. Not much tested, but it works with my block system. So now when a -marker word is encountered, interpret will continue with the next word. You can try and patch your FF with this, unless of course you are using Scamp words. IUNKNOWN: ; a f dec2 W14, W14 rcall CFETCHPP rcall TYPE rcall XSQUOTE .byte 2 .byte '\?',NAK_ .align 2 rcall TYPE ; rcall FALSE_ ; rcall QABORTQ bra INTER1 INTER6:
I quess the only solution for now is to use -marker from the command line and then load the file(s).
Yes. That's a problem with EVALUATE. A proper solution would be to implement CATCH/THROW in FF, so that EVALUATE could catch the error and continue. With a simple ABORT that is not possible.
when i have: -test marker -test ram create buf 20 allot ram create buf2 20 allot test2 buf c@+ evaluate buf2 c@+ evaluate ; s" : test 1 2" buf place s" + . ;" buf2 place test2 test 3 in a text file and I make copy and paste to the forth terminal, this works fine. but if I put this in a buffer and then I make evaluate, the system don't recognizes the -test word and give me aan error message and the evaluate stops. then i can not save files starting with -name marker -name. is there any way to solve...
I've finally managed to read an entire 4K text from external storage without worrying about truncated definitions or being stuck mid-word at the end of a 256-byte page of Scamp3e. I parse to the next CR (even if it's on the next page), save it in a 64-byte buffer, and then evaluate. It works perfectly even when a definition is evaluated in several parts, as you mentioned in your answer.
last : why buf c@+ evaluate buf2 c@+ evaluate doesn't work? and : test2 buf c@+ evaluate buf2 c@+ evaluate ; works.? It does not work because after the first evaluate the system is in compilation state so interpret will try to compile the phrase " buf2 c@+ evaluate" instead of executing it. The word test2 only executes so there is no dependence on state.
last : why buf c@+ evaluate buf2 c@+ evaluate doesn't work? and : test2 buf c@+ evaluate buf2 c@+ evaluate ; works.? It does not work because after the first evaluate the system is in compilation state so interpret will try to compile the phrase " buf2 c@+ evaluate" instead of interpreting it. The word test2 only executes so there is no dependence on state.
Using evaluate like this does not work. ram create buf 20 allot ram create buf2 20 allot s" : test 1 2" buf place s" + . ;" buf2 place buf c@+ evaluate buf2 c@+ evaluate
This works for me ram create buf 20 allot ram create buf2 20 allot : test2 buf c@+ evaluate buf2 c@+ evaluate ; s" : test 1 2" buf place s" + . ;" buf2 place test2 test 3
last : why buf c@+ evaluate buf2 c@+ evaluate doesn't work? and : test2 buf c@+ evaluate buf2 c@+ evaluate ; works.? It does not work because after the first evaluate the system is in compilation state so interpret will try to compile the phrase " buf2 c@+ evaluate" instead of interpreting it.
it works well. Good idea for some quick test.
Added words to temporarily compile code and execute it. Handy for timing tests or for compile-only words. Look in ARCH/forth/compile-execute.fs. [[ 10 for r@ . next ]] 9 8 7 6 5 4 3 2 1 0 ok<$,ram>
ALL: [[ ]]
thank you for the information. my idea was to have two buffer, a buffer 256 bytes and then a buffer of 64 bytes and a handle system. but now i'm thinking to have only one of 64 bytes and fill it reading the text until cr, evaluate and do the same until the end of file. i will check and try this idea and I will inform you. last : why buf c@+ evaluate buf2 c@+ evaluate doesn't work? and : test2 buf c@+ evaluate buf2 c@+ evaluate ; works.?
thank you for the information. my idea was to have two buffer, a buffer 256 bytes and then a buffer of 64 bytes and a handle system. but now i'm thinking to have only one of 64 bytes and fill it reading the text until cr, evaluate and do the same until the end of file. i will check and try this idea and I will inform you.
thank you for the information. my idea was to have two buffer, a buffer 256 bytes and then a buffer of 64 bytes and a handle system. but now i'm thinking to have only one of 64 bytes and fill it reading the text until cr, evaluate and do the same until the end of file. i will check and try this idea and I inform you.
When I was writing the block words I found that FF should be restructured to accept input from a large buffer using REFILL. But I never did that restructuring. Anyway it is easiest to have a line buffer that can accept a whole line, and evaluate one line at a time. If you take in only part of a line you may cut off some words in the middle which again a more difficult thing to handle. So LOAD has the restriction that one line is always 64 bytes and a word is not allowed to be split across a 64 byte...
When I was writing the block words I found that FF should be restructured to accept input from a large buffer using REFILL. But I never did that restructuring. Anyway it is easiest to have a line buffer that can accept a whole line, and evaluate one line at a time. If you take in only part of a line you may cut of some words in the middle which again a more difficult thing to handle. So LOAD has the restriction that one line is always 64 bytes and a word is not allowed to be split across a 64 byte...
what i really need: with loops and more accurate 1 ram create buf 20 allot 2 : test buf 20 evaluate ; 3 s" test3 1 2" buf swap cmove 4 test 5 buffer 20 erase 6 s" + . ;" buf swap cmove 7 test test3---->3 if this possible? my goal is evaluate a complet file of 4 K with a buffer of 256 bytes.
what i really need: with loops and more accurate ram create buf 20 allot test buf 20 evaluate ; s" test3 1 2" buf swap cmove test buffer 20 erase s" + . ;" buf swap cmove test test3---->3 if this possible? my goal is evaluate a complet file of 4 K with a buffer of 256 bytes.
what i really need: with loops and more accurate ram create buf 20 allot test buf 20 evaluate ; s" test3 1 2" buf swap cmove test buffer 20 erase s" + . ;" buf 8 + swap cmove test test3---->3 if this possible? my goal is evaluate a complet file of 4 K with a buffer of 256 bytes.
what i really need: with loops and more accurate ram create buf 20 allot test buf c@+ evaluate ; s" test3 1 2" buf swap cmove test buffer 20 erase s" + . ;" buf 8 + swap cmove test test3---->3 if this possible? my goal is evaluate a complet file of 4 K with a buffer of 256 bytes.