I attach a program, which is a (tabletop) project running on STK200, to add a speaker dependent voice control to my railroad layout, using Fortebit's EasyVR3 (the expression "Easy" is not really adapted, since the system is a "gaseous plant", look for the many configuration commands and for the handshake in lines 100 to 104). The result should be displayed on the Leds of the STK200. Now the issue : it occurs in line 131, which in fact behaves like : Travail = 17 +32(asterisk)Mode_passage_interactif ; it works only if I split it into 2 lines :
Travail = 17 + 2(asterisk)Numero_train_interactif
Travail = Travail + 32(asterisk)Mode_passage_interactif.
The same error occurs if I add parentheses around the multiplications, and with Mega162 too ..
Panic !
(64bit version of GC Basic, Build1132 by "patching")
Since I have no RS232 interface on my computer, I modified the program to display the result on the Leds. And Leds 1 to 3 were always off, this means that 2(asterisk)Numero_train_inetractif was discarded ...
Since I have no RS232 interface on my computer, I modified the program to display the result on the Leds. And Leds 1 to 3 were always off, this means that 2(asterisk)Numero_train_interactif was discarded ...
The root cause of the issue is the use of the MUL ( Multiplier ) of the 32 - this impacts the registers previously used for multiple of 2 calc.
So, knowing this... Travail=17+32*Mode_passage_interactif+2*Numero_train_interactif works. As This does the Multiplier* 32 first, adds 17, add the other calc.
I need to think on how to resolve this for the future.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Do You know the movie "Jinxed" (the story with the coin in the fountain ...), where Mr. Murphy works as a beta tester, assuming that according to Murphy's law, if anything could go wrong with a system it would happen to him ? I think finally that my other name is Murphy, too !
:)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is resolved in the new compiler ( build 1147 or greater).
If the calculation using the hardware multiplier is at risk of overwriting registers then it will use the software multiplier. This is a tad slower but very robust.
My reference code. This will ONLY work on version 1.xx.xx or build 1147 or greater.
/*Testcodeforcompiler*/#CHIPMEGA328P,16#OPTIONEXPLICIT#DEFINEUSART_BAUD_RATE9600#DEFINEUSART_TX_BLOCKING#DEFINEUSART_DELAYOFF'DetermineifAVRHardwareMultisenabled#IFDEFHardwareMult'Requiresv1.xx.xxofthecompiler#UNDEFINEHardwareMult#ENDIF'add,justcheckithasgone!#SCRIPTIFDEF(HARDWAREMULT)THENWARNING"HARDWAREMULT EXISTS"ENDIF#ENDSCRIPTDimNumero_train_interactifasByteDimMode_passage_interactifasByteDimTravailasByteWait2s#DEFINEOneLineCalc#IFDEFOneLineCalcHserPrint"Short Calc"HserPrintCRLF#ELSEHserPrint"Two Line Calc"HserPrintCRLF#ENDIFDoForMode_passage_interactif=1to3ForNumero_train_interactif=0to3#IFDEFOneLineCalc//OriginalmethodTravail=17+2*Numero_train_interactif+32*Mode_passage_interactif//othermethods//Travail=17+2*Numero_train_interactif+fnLSL(Mode_passage_interactif,5)//Travail=32*Mode_passage_interactif+17+2*Numero_train_interactif#ELSETravail=17+2*Numero_train_interactifTravail=Travail+32*Mode_passage_interactif#ENDIFHserPrintByteCRLFTravailNextNextHserPrintCRLF2wait2sLoop
Last edit: Anobium 2022-08-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Use the other methods for now but if you want to make sure the software maths is used.. open the CHIP DAT file and change HardwareMult=y to HardwareMult=n
But, it will only come in the GCStudio wrapper.
You can install GCStudio and then copy the install out.
But, get Angel to get it working for you OS.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Don't worry too much about my issue with Studio : I tested it, it didn't install, this is not the world's end ... About calculations : I signaled this for those people who NEED to make calculations ; in fact normally I would have performed these operations with a combination of shiftings and "or"s ; it was my first multiplication since 2018, and probavly the last one, too ! In my application program for the layout I need only bit operations, maskings, tests, additions and substractions, only operations very close to their equivalents in machine language.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Don't worry too much about my issue with Studio : I tested it, it didn't install, this is not the world's end ... About calculations : I signaled this for those people who NEED to make calculations ; in fact normally I would have performed these operations with a combination of shiftings and "or"s ; it was my first multiplication since 2018, and probably the last one, too ! In my application program for the layout I need only bit operations, maskings, tests, additions and substractions, only operations very close to their equivalents in machine language.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Features
•High-performance, Low-power AVR® 8-bit Microcontroller
•RISC Architecture
– 130 Powerful Instructions
– Most Single Clock Cycle Execution
– 32 x 8 General Purpose Working Registers
– Fully Static Operation
– Up to 16 MIPS Throughput at 16 MHz – On-chip 2-cycle Multiplier
The On-chip 2-cycle Multiplier is leveraged by Great Cow BASIC when HardwareMult=y. So, set to n to disable the use of MUL in the ASM but to use software multiplication.
Does this explain?
Last edit: Anobium 2022-08-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is no hardware multiplier on my older 8515 : https://ww1.microchip.com/downloads/en/DeviceDoc/doc2512.pdf
You are speaking of a newer version, the ATMEGA8515-16AUR
OK, so You are right when You write that I should disable it (I use "dinosaurs" from Atmel, before they came to Microchip)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The URL above.. shows the 'On-chip 2 cycle multiplier'.
I know the asm you shared uses MUL as the ASM shows that and you loaded the hex and it executed. If MUL was not supported then you would have an inoperable chip.
Have you changed the dat file? did you get correct maths?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
(Unfortunately) hello again
I attach a program, which is a (tabletop) project running on STK200, to add a speaker dependent voice control to my railroad layout, using Fortebit's EasyVR3 (the expression "Easy" is not really adapted, since the system is a "gaseous plant", look for the many configuration commands and for the handshake in lines 100 to 104). The result should be displayed on the Leds of the STK200. Now the issue : it occurs in line 131, which in fact behaves like : Travail = 17 +32(asterisk)Mode_passage_interactif ; it works only if I split it into 2 lines :
Travail = 17 + 2(asterisk)Numero_train_interactif
Travail = Travail + 32(asterisk)Mode_passage_interactif.
The same error occurs if I add parentheses around the multiplications, and with Mega162 too ..
Panic !
(64bit version of GC Basic, Build1132 by "patching")
Last edit: Bertrand BAROTH 2022-08-13
I can look into it. But, use two lines for now.
I knew such limitations in Bascom, and for concatenating strings in GCBasic, but not for calculation formulas in GCB ...
I have created this program.
On the 16F88 I get the same results as I do in Excel. I have modelled in Microsoft Excel.
So, there is a problem not in the calculation but in ASM generated from the calcs.
Please try this program on your chip. I need the results and the ASM.
Since I have no RS232 interface on my computer, I modified the program to display the result on the Leds. And Leds 1 to 3 were always off, this means that 2(asterisk)Numero_train_inetractif was discarded ...
Since I have no RS232 interface on my computer, I modified the program to display the result on the Leds. And Leds 1 to 3 were always off, this means that 2(asterisk)Numero_train_interactif was discarded ...
Unable to edit a post, text disappears, malfunction of the forum.
Thank you.
The root cause of the issue is the use of the MUL ( Multiplier ) of the 32 - this impacts the registers previously used for multiple of 2 calc.
So, knowing this...
Travail=17+32*Mode_passage_interactif+2*Numero_train_interactif
works. As This does the Multiplier* 32 first, adds 17, add the other calc.I need to think on how to resolve this for the future.
Do You know the movie "Jinxed" (the story with the coin in the fountain ...), where Mr. Murphy works as a beta tester, assuming that according to Murphy's law, if anything could go wrong with a system it would happen to him ? I think finally that my other name is Murphy, too !
:)
This is resolved in the new compiler ( build 1147 or greater).
If the calculation using the hardware multiplier is at risk of overwriting registers then it will use the software multiplier. This is a tad slower but very robust.
Meanwhile... these work
Travail=17+2*Numero_train_interactif+fnLSL(Mode_passage_interactif,5)
and
Travail=17+32*Mode_passage_interactif+2*Numero_train_interactif
Also, in the new compiler you can turn off the hardware multiplier yourself by undefining the constant.
#UNDEFINE HardwareMult
This will ensure the software routines are used.
Evan
Last edit: Anobium 2022-08-13
My reference code. This will ONLY work on version 1.xx.xx or build 1147 or greater.
Last edit: Anobium 2022-08-13
Where can I get a patch to upgrade at least to 1147 without using studio (which doesn't work on my Windows version) ?
It is a few days away.
Use the other methods for now but if you want to make sure the software maths is used.. open the CHIP DAT file and change HardwareMult=y to HardwareMult=n
But, it will only come in the GCStudio wrapper.
You can install GCStudio and then copy the install out.
But, get Angel to get it working for you OS.
Don't worry too much about my issue with Studio : I tested it, it didn't install, this is not the world's end ... About calculations : I signaled this for those people who NEED to make calculations ; in fact normally I would have performed these operations with a combination of shiftings and "or"s ; it was my first multiplication since 2018, and probavly the last one, too ! In my application program for the layout I need only bit operations, maskings, tests, additions and substractions, only operations very close to their equivalents in machine language.
OK re Studio
I would still disable HardwareMult until you get the new compiler.
Don't worry too much about my issue with Studio : I tested it, it didn't install, this is not the world's end ... About calculations : I signaled this for those people who NEED to make calculations ; in fact normally I would have performed these operations with a combination of shiftings and "or"s ; it was my first multiplication since 2018, and probably the last one, too ! In my application program for the layout I need only bit operations, maskings, tests, additions and substractions, only operations very close to their equivalents in machine language.
Still impossible to edit .. I had a misspelling (probavly) in my first post and wanted to modify it ...
:(
I would not worry.
I can no longer Edit when using Firefox Browser. However Opera and Chrome seem ok.
It was the AddBlocker. Disabled for this site and now editing is ok
William
Last edit: William Roth 2022-08-14
8515 and 162 have no hardware multiplier ...
The compiler is using it... line 129 in your ASM.
Please change HardwareMult as requested.
Then there is a more serious bug in the compiler (or the inc files), since it tries to use a hardware multiplier which doesn't exist on MEGA8515 !
Sorry, this may be some confusion here.
In the file mega8515.dat it shows.
HardwareMult=y
Set this ton
.Front page of the 8515 datasheet....
Features
•High-performance, Low-power AVR® 8-bit Microcontroller
•RISC Architecture
– 130 Powerful Instructions
– Most Single Clock Cycle Execution
– 32 x 8 General Purpose Working Registers
– Fully Static Operation
– Up to 16 MIPS Throughput at 16 MHz
– On-chip 2-cycle Multiplier
The On-chip 2-cycle Multiplier is leveraged by Great Cow BASIC when
HardwareMult=y
. So, set ton
to disable the use of MUL in the ASM but to use software multiplication.Does this explain?
Last edit: Anobium 2022-08-14
There is no hardware multiplier on my older 8515 :
https://ww1.microchip.com/downloads/en/DeviceDoc/doc2512.pdf
You are speaking of a newer version, the ATMEGA8515-16AUR
OK, so You are right when You write that I should disable it (I use "dinosaurs" from Atmel, before they came to Microchip)
The URL above.. shows the 'On-chip 2 cycle multiplier'.
I know the asm you shared uses MUL as the ASM shows that and you loaded the hex and it executed. If MUL was not supported then you would have an inoperable chip.
Have you changed the dat file? did you get correct maths?