Pin Change Interrupt PCINT ATtiny10

After having a little fun. I learned a few things about this chip.. Pullups are different..

My goal on this was to just figure out Pin Change interrupts, just reading datasheet. One thing I found is you can't select whether falling, rising, etc.. So I had to add a little more code compared to external interrupt INT0 . The advantage of this is I can use other pins for interrupt other then just PB2.

It works..

Her is the code I used for Pin Change interrupt on PB2 works great. I did add a .1uf Cap on GND to PB2 for de-bounce.

/* Testing Pin Change interupt on Attiny10 on PB2
Sherm 11/8/2021*/
#define F_CPU 1000000UL#include <avr/io.h>#include <avr/interrupt.h>#include <util/delay.h>
volatile uint8_t loops = 0;
int main(void){
//EICRA=0b00000010; //detect falling edge ext int on ISC0 0 and 1 //EIMSK=0b00000001; // turn on INT0 PCICR |= (1<<PCIE0); //Enable PC interrupts PCMSK |= (1<<PCINT2); //select pin(s) for interrupt, this one is PB2 DDRB=0b00000010; //set PB1 as output and rest as input PUEB=0b00000100; //enable pullup attiny10 on PB2 //PORTB|=(1<<PB2); //enable pullup NOT ON ATTINY10 sei(); while(1){ }}
// Interrupt Service RoutineISR(PCINT0_vect){ //since PCinterrupt detects all changes we have to ignore first round loops++; if(loops>=2){ PORTB ^=(1<<1); loops=0; } }