Тёмный

How to use the Pin Change Interrupt on ATtiny85 

insideGadgets
Подписаться 1,3 тыс.
Просмотров 31 тыс.
50% 1

Опубликовано:

 

29 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 45   
@ckatke
@ckatke 3 года назад
Just want to let you know that eventhough it has been more than 10 years since you posted this video, it is still useful! You did a great job coming up with a very simple demo of pin change interrupt. Excellent explanation too. Thank you!
@HariWiguna
@HariWiguna 9 лет назад
Just want to let you know that eventhough it has been four years since you posted this video, it is still useful! You did a great job coming up with a very simple demo of pin change interrupt. Excellent explanation too. Thank you!
@eznAnze
@eznAnze 3 года назад
10 years later, still the best video out!
@Joso997
@Joso997 2 года назад
High-quality video from 2011. You don't see that often.
@edwardlong3312
@edwardlong3312 4 года назад
Thanks, I looked at many videos on the internet and found yours the clearest. I was able to convert it from a PCINT to INT0, which is what I needed for my application.
@jonduncan05
@jonduncan05 8 лет назад
I thought I was fighting button bounce and spent way to much time last night. I now see I was getting two interrupts with each button press as I was getting rising and falling edges. Thank you!
@oscarbear1043
@oscarbear1043 6 лет назад
I have found the SMD ATTINY85 to be useful in many projects, if you purchase a programming clip and use an Arduino as a ISP you can put lots of Arduino code on one. I use them to save space and money In addressable led projects. You do need a breakout board and if you buy a clip make sure to get one to suit the package you are using the first one I ordered was incorrect and I waited weeks for delivery only to be disappointed. Thank you for your excellent tutorial.
@domi2712
@domi2712 3 года назад
2021 - Thanks for your explaination!
@titokrissel4474
@titokrissel4474 Год назад
Hello. Thank you very much for your demonstration, I will try to do it. Cordial greetings from Argentina. Spanish: Hola. Muchas gracias por tu demostración intentaré realizarlo. Cordial Saludo desde Argentina.
@StevenMcconnon
@StevenMcconnon 11 лет назад
Thanks. I would love to be as knowledgable as you one day at electronics, I'm a senior Comp. Eng. student but the degree doesn't hold a candle to real life experience.
@insidegadgets
@insidegadgets 12 лет назад
That was intentional, the ATtiny85 doesn't have an individual ISR for each pin. PCINT0 stands for Pin Change Interrupt Request 0 and PCMSK is the Pin Change Mask Register. We enable the pin change interrupt on the PCINT1 pin in the PCMSK. If you also enabled pin change on PCINT2 pin and an interrupt occurred on either pins, both would go to the PCINT0 ISR. You can check the interrupt vectors (e.g. PCINT0) on page 50 on the ATtiny85 datasheet and the PCMSK register on page 53.
@Coolfolder
@Coolfolder 7 лет назад
This was really clear and fantastic, thank you!
@ljay0778
@ljay0778 3 года назад
Excellent video, Thank you. But one thing I saw is that you had nothing in the ISR. If you cut out everything you wrote in loop() and put and empty while() {} loop in there, then paste what you had in loop() in the ISR(PCINT0_vect) {} ; That it will run as intended, and independently of the void loop() which is what we want. Again I say great! video and demo: One of a kind on youtube_
@javier-tk5ff
@javier-tk5ff 5 лет назад
Hi! Great job! I have a doubt, because when I measured the circuit, when I have the switch is open the consumption is 0.68 in sleep mode, but when the switch is close is 0.0 in sleep mode. I think I have some wrong, because I hope the same consumption in tow modes. Thanks a lot.
@insidegadgets
@insidegadgets 12 лет назад
GIMSK and PCMSK should be part of the Input/Output (IO) of the ATtiny, just like PORTB, PINB, etc are. You would need to make sure you include the avr/io.h file and that in the makefile you specify your AVR device (MCU = attiny84)
@POOFjunior
@POOFjunior 12 лет назад
Ah, yes--of course! My apologies. Under Tools-->Board, I had still selected Arduino Uno, rather than Attiny85. Many thanks for noting this!
@NeonblueIndustries
@NeonblueIndustries 5 лет назад
A way to use INTERUPTS AND THE DELAY FUNCTION! NICE!!!!! Is this possible ONLY because you did the Pin Change Interupt? Or is it possible on the standard Interrupt Pins of the AtTiny85? Thanks.
@insidegadgets
@insidegadgets 5 лет назад
Hi, yes it's because the interrupt is a pin change interrupt and not a timer interrupt which I believe the Arduino uses for the delay function. If you code direct AVR instead of Arduino, there is a delay_ms function which is tied to the clock speed and doesn't use any interrupts. You could probably do that with Arduino too but would have to make sure that some how it doesn't use the timer interrupt.
@NeonblueIndustries
@NeonblueIndustries 5 лет назад
Where do I get the library from, What is the title of it to search in the library manager?
@algre977
@algre977 3 года назад
Is there any way to know which pin triggered the interrupt in case you have multiple triggers ?
@insidegadgets
@insidegadgets 3 года назад
Yes, you just have to check the pin state in the interrupt
@thebloody_blue
@thebloody_blue 4 месяца назад
Watching after 13 years 🎉
@POOFjunior
@POOFjunior 12 лет назад
Many thanks for this awesome introduction to the attiny85's interrupt capabilities! This seems like a fundamental question, but do you know how you're avoiding errors like some of the values: GIMSK and PCMSK not being declared in this scope?
@penpencool
@penpencool 9 лет назад
Great , Good work
@GTvideoHD
@GTvideoHD 3 года назад
it's possible that the interruption blocks the upgrading of a new program?
@insidegadgets
@insidegadgets 3 года назад
Hi Andres, you should still be able to upload code because the ATtiny has a dedicated reset pin, once it goes low the chip will be ready to be re-programmed. If you have connections hooked up to SCK, MOSI, MISO in your circuit, then that could cause a problem
@GTvideoHD
@GTvideoHD 3 года назад
@@insidegadgets you're right, it was just a bad contact between the reset (digital pin13 on arduino) and the protoboard pad connected to the Attiny85 reset pin. Thanks bro
@markusrohner9452
@markusrohner9452 8 лет назад
Hi, great video. I still have a question though. When an interrupt occurs what is the first command executed? Is it the first statement in the loop()?
@insidegadgets
@insidegadgets 8 лет назад
+Markus Rohner Hi Markus, when an interrupt occurs, it jumps to ISR(PCINT0_vect) to execute code (in this example we don't have any) and then it jumps back to the place after we set the system_sleep() command, which in this case as it's at the end of the loop, it would bring us back to the start of the loop.
@DiyintheGhetto
@DiyintheGhetto 9 лет назад
Hello i was wondering how much power does it take while in sleep mode maybe i miss that? The other question is how long does it take to wake up and turn on the led looks pretty quick?
@insidegadgets
@insidegadgets 9 лет назад
+joseph chrzempiec (josephchrzempiec) Hi, once the ATtiny85 is in sleep mode, it only takes 1-4uA (depends on what else you leave on) and it would take 4 cycles (pin interrupt) plus 6 cycles when at 1MHz using internal clock to wake up from power down, so about 10uS.
@wltr2302
@wltr2302 8 лет назад
+insideGadgets hello is it possible to put the reset pin as the interrupt pin?
@insidegadgets
@insidegadgets 8 лет назад
Yes if you change the fuses, the reset pin can act almost like a regular pin but the downside is that once you do this you need a high voltage programmer if you wish to program the chip.
@Coolfolder
@Coolfolder 7 лет назад
Why is it PCINT0_vect instead PCINT1_vect when it PB1 we are changing? Is it that all pins will call the PCINT0_vect register? I'm guessing that's what you're speaking of at 3:17-3:30. I think the "0" in PCINT0_vect is misleading though
@WhoWantsToKnow81
@WhoWantsToKnow81 7 лет назад
Yes, it is really misleading. PCINT0_vect be triggered for those pins for which the interrupt has been activated (PB[0:5])
@TheDanzman1211
@TheDanzman1211 10 лет назад
I am just wondering if this will work using a capacitative sensing plate.
@insidegadgets
@insidegadgets 10 лет назад
If you have a chip built in with the sensoring plate and it puts out about half of the VCC voltage it should work. If it's just a bare plate alone, then you could put a 1M or higher resistor to ground.
@TheDanzman1211
@TheDanzman1211 10 лет назад
insideGadgets I have the plate connected to pin 3 with a crossover 470M resistor connected to pin 8 . The capacitative sensing works. The problem is the sensing routine is in the loop and the subroutine does not get executed until some parts of the program are done. That is why I need to place the subroutine in the interrupt. Any hint how to do this? Thanks.
@Kz-ey7mq
@Kz-ey7mq 7 лет назад
hello.. I compiled your code in Arduino IDE , it's showing sfr not define. So can you tell me, how to fix this problem.
@insidegadgets
@insidegadgets 7 лет назад
Hi, please try this version - pastebin.com/v7nxePgi
@weerobot
@weerobot 4 года назад
Awesome..
@RahulSingh-my7vx
@RahulSingh-my7vx 6 лет назад
why it is showing yenkie invalid device check your connection double
@insidegadgets
@insidegadgets 6 лет назад
Hi, please check your connections are correct. Sometimes I get this if there isn't a capacitor near the MCU, sometimes a 0.1uF cap will fix it but if not, try 1uF.
Далее
Atmega328 -  External Interrupts Code Example
2:49
Просмотров 5 тыс.
Ледник 1:0 Мужик
00:53
Просмотров 1,3 млн
FLProg. Программа робота на Attiny
18:26
Using External Interrupts
3:31
Просмотров 3,9 тыс.
Preparing Blank ATtiny85 for programming
5:19
Просмотров 2,2 тыс.