Hi @silverstar,
As Ron (@zander) is showing, Arduino has some 'cleverer stuff' than I knew about. As I said, I was just using the old basic tricks from long forgotten microprocessors running a simpler programme structure!
Personally, I would just start with the AND + OR statements I suggested previously, and 'temporarily forget' about the chance of something sneaking in between the two lines of code, and see how you get on.
Unless the programme repeatedly executes those two lines, which I think is unlikely, then I think there is a pretty low (to zero) chance of anything sneaking in.
When you have got it working and feel comfortable, then would be a good time to follow up Ron's leads, and hopefully the details will be easier to follow then as well.
Good luck, Dave
@silverstar Ok, I will check if my recommendations are for the Arduino or the ESP32 when I have time. The general approach will not be much, if any, different, I just need to double-check the API.
The bit setting is the same. That's just C code, it's the critical sectioning I need to check.
FYI, 99.9% of my electronics stuff is stuck halfway across the country, so I am limited in testing ability, but I did just get a new UNO R4 and a NANO ESP2 so I think I can do a meaningful test. I have a truck safety check tomorrow morning for the new license but after that, I will try a few things.
Can you tell me if the setting of the scalar bits is being done once in setup or is it changing in the loop? If it's a one-time thing, make it the very first thing, especially before setting up your Serial connection. Of course, wrapping even that in a critical section is safer but if it's one time and first the chances of a fubar are very tiny.
Good luck.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
@silverstar Have a look at this link, look for the Arduino examples. https://www.instructables.com/Arduino-Timer-Interrupts/
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
@Ron suggested that I read /timer interrupts
//by Amanda Ghassaei
//June 2012
// https://www.instructables.com/id/Arduino-Timer-Interrupts/
Amanda was very helpful and with that guidance, I was able to get my project off first base. The timer aspect is working as desired.
Thank you all for your input.
Fred Stout aka SilverStar
@silverstar Fred, Excellent, I just did a google and sent the link, my knowledge is not that deep on timers. BTW, my name is Ron but my 'handle' here is @zander.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
@zander hi Ron,
I do all of the initialization of the timer once in setup.
What I have observed is the setting of the compare match register. I do it once in setup and never again. Some examples I have seen reset compare match register in the ISR. I am wondering how that actually works.
The biggest problem I have had (once the interrupt worked) was reading the GPS data when there was an interrupt. Seems to work now though.
Thanks again for your help.