Go Down

Topic: attiny 85 two interrupts (Read 194 times) previous topic - next topic

GolamMostafa

So? What's the problem with it using timer0?
If I decide to go in my prescribed way, I would be polling the K1 while delay is being generated by repeated interrupts of T0. I clearly see that there exists a 'software racing' between two routines; I am again afraid that I might not be able (due to my own limitations) to manage the situation in case there is a collision. 

septillion

Then why would you use T0 to do something as simple as polling? And dump all the Arduino HAL out of the window?
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

pratto

ok. I get it. I actually think I get it. And the code is so clean and concise. I have been trying to figure this out for years. A guy wrote me a sketch to do it, but it is about 80 lines long, and I never understood it (WDT, Flags, MCUCR, detachInterrupt, atomic library, and more.

I am going to try and remember how to program an attiny, and breadboard this up.

A couple of things : instead of ON for 6 minutes then off, I want ON for 6 hours. But it doesn't have to be accurate. 1/2 hour each side will be fine. Will using millis() still work ?

The other thing is, I am trying to really get the power consumption down (when the LED is OFF) by turning the ADC off, and using Power Down. Will my interrupt bring me out of power down ?


GolamMostafa

So? What's the problem with it using timer0?
If I decide to go in my prescribed way, I would be polling K1 while the time delay is being generated by repetitive interrupts of T0. I clearly see that there might exist a 'Software Racing' between two routines. I am again afraid that I might not be able to manage (due to my own limitations) the situation in case there is a collision. Moreover, I have seen some Forum Members terming it 'Notorious interrupt if could not be managed properly.'  

septillion

If you write it from scratch (aka, not use all the Arduino functions/libaries) it might indeed look a bit more scary ;)

A couple of things : instead of ON for 6 minutes then off, I want ON for 6 hours. But it doesn't have to be accurate. 1/2 hour each side will be fine. Will using millis() still work ?
Millis() will probably have less error then the 8% you suggested so as long as you don't expect a period of 50 days (and I don't mean you can have the Arduino of for 50days, just a simple led blink should be less then 50 days) you're fine!

The other thing is, I am trying to really get the power consumption down (when the LED is OFF) by turning the ADC off, and using Power Down. Will my interrupt bring me out of power down ?
There are multiple sites which have that info including the datasheet ;) But on the top of my mind I think the external interrupt can wake all modes of sleep.

@GolamMostafa, But why do the polling with a timer? Why not just poll as damn many times as the uC can? (aka, just do it in loop)

Or, use millis() to time the polling as well. That's why there is such a higher level function for timing in the first place ;)
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

DrAzzy

PCINTs can wake from sleep.

INT0 can wake from sleep ONLY on low level interrupt, not rising/falling, which is somewhat less convenient:
Quote
When the INT0 interrupt is enabled and is configured as
level triggered, the interrupt will trigger as long as the pin is held low.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

pratto

#21
Mar 20, 2017, 07:13 pm Last Edit: Mar 20, 2017, 07:20 pm by pratto
Septillion-

All I can say is thank you.

And, as I understand it, taking the time to straighten beginners out is a bit of a sacrifice for successful programmers as it keeps them away from dating beautiful women.  :)

septillion

Luckily I already have a gorgeous girlfriend :D Maybe that's why I have some spare time :D
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy