Page 1 of 1
Lut table inside interrupt
Posted: Mon Nov 25, 2024 6:18 am
by viktor_au
Hi
lut table works OK inside the interrupt macro, however the main macro is not. Test B5 does not flash.
If I use the lut table outside of interrupt (before the main macro) B5 flash OK, but the interrupt does not work.
Any help, please?
Re: Lut table inside interrupt
Posted: Mon Nov 25, 2024 11:01 am
by chipfryer27
Hi
Can you attache your chart?
Regards
Re: Lut table inside interrupt
Posted: Mon Nov 25, 2024 9:54 pm
by viktor_au
Hi
One more question.
I understand, that locals in interrupt macro is not saved.
I need to use static or globals.
What is the best?
Re: Lut table inside interrupt
Posted: Tue Nov 26, 2024 8:13 am
by chipfryer27
Hi
Locals (e.g. .x) are used within the macro itself and nowhere else.
If you had Macro-1 / Macro-2 / Macro-3 each of them could use a variable called .x only avaiable within that macro itself. Useful to save space.
Global variables are available throughout your program. If you assign a value to "x" anywhere then that value is available wherever "x" is used. If you assign x=4 in Macro-1, in every other Macro x already equals 4 until assigned a new value (anywhere).
Regards
Re: Lut table inside interrupt
Posted: Tue Nov 26, 2024 9:57 pm
by viktor_au
Hi chipfryer
If Lut table inside the interrupt,
- the interrupt macro works, but
- the main macro does not work.
If Lut table outside the interrupt,
- the interrupt macro does not work, but,
- the main macro works.
Re: Lut table inside interrupt
Posted: Wed Nov 27, 2024 4:30 am
by chipfryer27
Hi
Not an expert in "C" which is why I use Flowcode <s>
I'm guessing that the issue is to do with the "C" commands used. Is there any reason you cannot use the FC components to do as you wish, even just to test?
I did notice that in your LUT component properties you have set "Embed into C" as No, which means that it is simulation only.
As FC can't simulate interrupts I added a Macro to call Timer1 ISR macro within your Main loop, which simulated fine. I have no access to any hardware just now so cannot try anything out.
Regards
Re: Lut table inside interrupt
Posted: Wed Nov 27, 2024 9:40 pm
by viktor_au
Hi
The lut component is not used (should not be included).
The Interrupt uses C to create a direct access to Timer1 .
I will check today the program (without the lut component).
I am not sure, but (probably) the included (but not used) lut component can create some problems.
Re: Lut table inside interrupt
Posted: Wed Nov 27, 2024 11:37 pm
by viktor_au
Hi
I have tried to include the lut component (removed the C-icon (lut)).
I have the error: lut undeclared... or other errors.
------------
If I remove the lut as an integer array or as a FC8 lut component, and use
(for example) ten values, instead of 100 lut values inside the interrupt
0, 247, 470, 647, 761, 800, 761, 647, 470, 247
-----
If x=1, value= 0
If x=2, value= 247
If x=3, value= 470
If x=4, value= 647
etc...
All good. The hex is created and Nano works OK.
Interrupt works and main macro works as well.
There is a problem in saving (sending?) lut value
from the lut table into the interrupt macro.
Re: Lut table inside interrupt
Posted: Thu Nov 28, 2024 7:14 am
by chipfryer27
Hi
In your "Out" chart in earlier post:-
In the LUT properties you have a facility to enter the values. These count from 0. I set it to have the first ten values as 0,1,2,3,4,5,6,7,8,9............ with the last one 1000.
I disabled your C-block that sets values.
I changed your Timer1 interrupt to use the Timer1 interrupt set at roughly 1Hz.
In your main loop I included a Count (from 0), and a LUT GetInt based on count value
In Project Debugger I included Count and Ret (from LUT table).
When running, the LUT outputs 0,1,2,3,4,5 etc no issue, and timer1 Macro is called and runs.
This compiles to Hex OK (with LUT set to Embed)
I then enabled your C-block that attempts to populate the LUT. This too compiles to Hex without any issue. However as I can only simulate I don't know if it does anything or not (FC can't simulate C).
Regards
Re: Lut table inside interrupt
Posted: Thu Nov 28, 2024 9:41 pm
by viktor_au
Hi
Can you add your chart, please.
Re: Lut table inside interrupt
Posted: Fri Nov 29, 2024 12:20 am
by viktor_au
The Atmega 328 ROM size is 1kB.
As LUT table uses the ROM:
I can store only 100 values with 10 byte in one value.
-----------------------
As I want to store 100 integers, the storage size should be 16x100=1600 bytes (at least).
Is it a problem?
Re: Lut table inside interrupt
Posted: Fri Nov 29, 2024 1:51 am
by chipfryer27
Hi
Attached is my v8 file (and Hex)
In LUT properties I changed the first few values to be 0-10 with 1000 being last.
I changed your custom timer to be Timer1 running at approx 1Hz, included a Count variable (start at 0) and LUT based on Count value. It cyces through displaying the expected LUT values.
Can't comment on your C-code to modify LUT as I have no access to hardware.
Compiles to Hex OK
My understanding is that the LUT values are stored in the same place as your "program" itself, in this case the 32K of memory so you should be good.
Regards
Re: Lut table inside interrupt
Posted: Fri Nov 29, 2024 9:44 pm
by viktor_au
Understood.
Thank you for your help.