I am trying to put Forth on Pro Micro (ATmega32U4) unsuccessfully. When I upload the 32u4-16MHz-USB.hex file and connect the Pro Micro to a Windows 10 PC I either get nothing or the device gets recognised but with errors. More details can be found here.
Can somebody verify the hex file in the current distribution is working on Pro Micro boards, please?
Last edit: Glaukon Ariston 2021-11-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the quick reply. I have verified I have the 5V, 16MHz version of Pro Micro (16MHz crystal on board). Uploading the 32u4-16MHz-USB.hex file again with the recommended fuses I get the following output from avrdude. The efuse got set to CF instead of FF. Upon connecting it to the PC I get the device enumerated but with the exclamation mark in the Device Manager. The USB Device Tree View app shows the descriptors with the relevant Status and Problem Code.
I am using linux so I have not tested it with windows. There seems to be a descriptor problem.
Windows is more strict than linux with the descriptors.,
I will check.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for your effort! I can confirm that the new hex file works. At least I got the command prompt ok<#,ram>, I haven't investigated further yet. Also, it works only in TeraTerm -- it does not work with PuTTY or RealTerm (at least I haven't managed to make it work). PuTTY complains that it cannot connect to COM port saying Unable to open connection to COM13. Unable to configure serial port.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The code and hex files are now updated to work also with PuTTY and and MyFFshell.
There was a protocol handling error in the SET_LINE_CODING message code.
So hopefully FF now works with all terminal programs.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@oh2aun I have managed to successfully compile the hex file. Now, I would like to add some Forth words to the image (e.g. port definitions) -- how do I do that?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It is also possible to write the dictionary links with a reusable label '9' and refer with '9b' backwards to the previous label.
Then a macro could be made to read the ports from a file instead. This has already been implemented for the PIC24.
See pic24/src/registers.inc
These reusable labels are a feature of GNU assembler which is used for Atmega and PIC24.
Sadly the assembler used by the XC8 for PIC18 is not based on GNU and it is highly optimzed for the PIC18 C compiler.
Last edit: Mikael Nordman 2021-11-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That was really quick. Thanks! I see you made a macro mreg for simplifying the port definitions. I will play around with it and come back with more questions ;-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is it possible for the assembler to calculate the length of the name? For example length("\name") in the mreg macro. Also, where can I find documentation for the .macro directive?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have changed the definition of mreg so it does not require the name length parameter.
; Macros for registers.macromregreg,name,flagsfdw9b.equname_len,2f-1f9:.byteNFA|\flags|name_len1:.ascii"\name"2:.align1m_duplditosl,lo8(\reg)lditosh,hi8(\reg)ret.endm
I have also expanded the port definitions in the registers.inc
Now I would like to implement a similar set of Forth words as in this YouTube video, e.g. .pins, mem, .pullup, flush, times, many, extend, ... Do I have to implement them all in assembler or is it possible to bundle Forth words written in Forth inside the hex file?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I did a little bit of refactoring. Now there is a separate macro m_header that you can use to initialise the word header. This can simplify and shorten the code and make it more robust against the errors. Also you would not need to define all those extra link labels (e.g. SCAN_L).
.macrom_headername,flagsfdw9b.equname_len,2f-1f9:.byteNFA|\flags|name_len1:.ascii"\name"2:.align1.endm; Macros for registers.macromregreg,name,flagsm_header\name,\flagsm_duplditosl,lo8(\reg)lditosh,hi8(\reg)ret.endm
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
is now available.
There are ready made hex files, one with UART operator console, and one with USB operator console.
https://sourceforge.net/p/flashforth/code/ci/master/tree/avr/hex/32u4-16MHz-UART38400.hex
https://sourceforge.net/p/flashforth/code/ci/master/tree/avr/hex/32u4-16MHz-USB.hex
Mikael
I am trying to put Forth on Pro Micro (ATmega32U4) unsuccessfully. When I upload the
32u4-16MHz-USB.hex
file and connect the Pro Micro to a Windows 10 PC I either get nothing or the device gets recognised but with errors. More details can be found here.Can somebody verify the hex file in the current distribution is working on Pro Micro boards, please?
Last edit: Glaukon Ariston 2021-11-13
You are using the wrong fuse values.
Check here.
https://flashforth.com/atmega.html
And you have to use the 16 MHz version of the Pro Micro. Not the 8 MHz version.
Last edit: Mikael Nordman 2021-11-13
Thanks for the quick reply. I have verified I have the 5V, 16MHz version of Pro Micro (16MHz crystal on board). Uploading the
32u4-16MHz-USB.hex
file again with the recommended fuses I get the following output fromavrdude
. Theefuse
got set toCF
instead ofFF
. Upon connecting it to the PC I get the device enumerated but with the exclamation mark in the Device Manager. The USB Device Tree View app shows the descriptors with the relevantStatus
andProblem Code
.avrdude
USB Device Tree View
I am using linux so I have not tested it with windows. There seems to be a descriptor problem.
Windows is more strict than linux with the descriptors.,
I will check.
I have updated the code and hex files to work with windows.
It now works with TeraTerm. MyFFshell does not work for some reason.
Thank you for your effort! I can confirm that the new hex file works. At least I got the command prompt
ok<#,ram>
, I haven't investigated further yet. Also, it works only in TeraTerm -- it does not work with PuTTY or RealTerm (at least I haven't managed to make it work). PuTTY complains that it cannot connect to COM port sayingUnable to open connection to COM13. Unable to configure serial port
.The code and hex files are now updated to work also with PuTTY and and MyFFshell.
There was a protocol handling error in the SET_LINE_CODING message code.
So hopefully FF now works with all terminal programs.
@oh2aun I tried compiling the source code myself. The resulting hex file does not enumerate under Windows 10. Any ideas what am I doing wrong?
I have only updated the XC8 source files.
I will remove the AVRASM2 source files from git soon.
See https://flashforth.com/atmega.html
@oh2aun I have managed to successfully compile the
hex
file. Now, I would like to add some Forth words to the image (e.g. port definitions) -- how do I do that?Here is one example.
Notice the dictionary links (fdw ...)
Last edit: Mikael Nordman 2021-11-27
It is also possible to write the dictionary links with a reusable label '9' and refer with '9b' backwards to the previous label.
Then a macro could be made to read the ports from a file instead. This has already been implemented for the PIC24.
See pic24/src/registers.inc
These reusable labels are a feature of GNU assembler which is used for Atmega and PIC24.
Sadly the assembler used by the XC8 for PIC18 is not based on GNU and it is highly optimzed for the PIC18 C compiler.
Last edit: Mikael Nordman 2021-11-27
Now you can add your register definitions in
avr/src/registers.inc
That was really quick. Thanks! I see you made a macro
mreg
for simplifying the port definitions. I will play around with it and come back with more questions ;-)Is it possible for the assembler to calculate the length of the name? For example
length("\name")
in themreg
macro. Also, where can I find documentation for the.macro
directive?google 'gnu assembler manual'
I have changed the definition of
mreg
so it does not require the name length parameter.I have also expanded the port definitions in the
registers.inc
Now I would like to implement a similar set of Forth words as in this YouTube video, e.g.
.pins, mem, .pullup, flush, times, many, extend, ...
Do I have to implement them all in assembler or is it possible to bundle Forth words written in Forth inside thehex
file?Well Done ! I will include the new macro into FF.
You have the write those words in assembler.
One could implement a mechanism that interprets and compiles forth from a text buffer in flash.
But that does not exist in FF.
Last edit: Mikael Nordman 2021-11-27
I did a little bit of refactoring. Now there is a separate macro
m_header
that you can use to initialise the word header. This can simplify and shorten the code and make it more robust against the errors. Also you would not need to define all those extra link labels (e.g.SCAN_L
).I can confirm that it now works well with TeraTerm, PuTTY and RealTerm on Windows 10.
@glaukon btw, In recent realterm versions (43+) it will show you what windows knows about the USB device when it enumerates. https://sourceforge.net/p/realterm/news/2017/10/30141/