Yes simple interrupts could and should replace Waits.
That is the Primary thinking behind the Millis Function in Arduino and GCBASIC.
Rather than sit in a loop wasting cycles you can look at elapsed time and if it is not up return control to the next operation.
If the Time is up, then you Toggle the LED, or whatever function the wait is controlling and then return control to the next task..
Simple Multitasking.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I posted about using millis for a wait solution but anobium says it all works in multiples of 2 not for running a pic at 41KHz. I think wait works for set frequencies.
Using interrupts can be difficult to learn how... and how much code can be used before the next interrupt. You don't want a program to be mainly running an interrupt.
I mostly use a mega328p so only one lot of interrupts to learn and the freqcalc program link in help is handy.
At least gcb uses real interrupts but for a beginner like me they seem seem to be surrounded in mystery when in fact they are, depending on the ucontroller, not that hard to understand and use.
I wouldn't want to set up a pps pic interrupts... got to understand data sheets :(
It's why I use a uno/nano board with gcb, I can use the board labels like digital4 and not have to look up what port it is.
I got a do-every interrupt working with 328p. I could have used the millis() function but it worked, just counters for each event.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Would have to see the code with the error. But, pass a string variable to ensure the size is correct. So, do not do str(var)+" " as this uses the sysstringvararialbe and uses more RAM, the size of the sysstringvararialbe may be 1 (not 2).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes simple interrupts could and should replace Waits.
That is the Primary thinking behind the Millis Function in Arduino and GCBASIC.
Rather than sit in a loop wasting cycles you can look at elapsed time and if it is not up return control to the next operation.
If the Time is up, then you Toggle the LED, or whatever function the wait is controlling and then return control to the next task..
Simple Multitasking.
I posted about using millis for a wait solution but anobium says it all works in multiples of 2 not for running a pic at 41KHz. I think wait works for set frequencies.
Using interrupts can be difficult to learn how... and how much code can be used before the next interrupt. You don't want a program to be mainly running an interrupt.
I mostly use a mega328p so only one lot of interrupts to learn and the freqcalc program link in help is handy.
At least gcb uses real interrupts but for a beginner like me they seem seem to be surrounded in mystery when in fact they are, depending on the ucontroller, not that hard to understand and use.
I wouldn't want to set up a pps pic interrupts... got to understand data sheets :(
It's why I use a uno/nano board with gcb, I can use the board labels like digital4 and not have to look up what port it is.
I got a do-every interrupt working with 328p. I could have used the millis() function but it worked, just counters for each event.
I am looking for further help to resolve a bug in AVR string concatenation.
If you are an expert on AVR ASM and you can spend a few hours to help resolve a bug then please ping me.
The issue within the string support libraries and can be seen by this simple program.
The terminal gets
013
not0123
The error is specific. Needs to be fixed. Got time and expertise to help?
I had trouble with glcdprint (10,10,str(var)+" ",ili9341white)
or something similar to print a var and a following space.
Would have to see the code with the error. But, pass a string variable to ensure the size is correct. So, do not do str(var)+" " as this uses the sysstringvararialbe and uses more RAM, the size of the sysstringvararialbe may be 1 (not 2).
like
mystr=str(var)
glcdprint (10,10,mystr+" ",ili9341white)
that's more ram for mystr?
var could be 3 digit then 1 so need to follow with 2 spaces.