Notifications
Clear all

Setting Timer Interrupt Options (Registers?)

22 Posts
3 Users
5 Likes
992 Views
(@davee)
Member
Joined: 3 years ago
Posts: 1697
 

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


   
ReplyQuote
(@silverstar)
Member
Joined: 3 years ago
Posts: 18
Topic starter  

@zander Arduino Uno


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7015
 

@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, and 360, fairly knowledge in PC plus numerous MPU's and 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.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7015
 

@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, and 360, fairly knowledge in PC plus numerous MPU's and 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.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
DaveE reacted
ReplyQuote
(@silverstar)
Member
Joined: 3 years ago
Posts: 18
Topic starter  

@zander, @Ron, @Davee

@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


   
DaveE reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7015
 

@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, and 360, fairly knowledge in PC plus numerous MPU's and 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.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
DaveE reacted
ReplyQuote
(@silverstar)
Member
Joined: 3 years ago
Posts: 18
Topic starter  

@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.


   
ReplyQuote
Page 2 / 2