简体   繁体   中英

Can I use PCINT0 and PCINT1 for all pin interrupts on atmega328pb?

I am trying to make it so that then PINB7 is pressed (which is pin of botton) LED to light up. PINB7 is PCINT8 on board. So i set

PCICR|=(1<<1);//enable interrupts for pins 14-8
sei();
PCMSK1|=(<<PCINT8); // mask for pin 8

i don't get what vector i should use in ISR. From what i saw I should just do PCINT8_vect, however vector doesn't get highlighted like then i use "TIMER2_COMPB_vect".So does PCINT8 vector not exist or is there way to use PCINT0 and 1 for this?

Apparently , on mega328pb , there is no vectors for individual pin interrupts but there are vectors for PCIE0,1,2,3. 0- bits 0:7 1-8:14 2-16:23 3-24:27

so if u want to use interrupt for pin b7. PB7 is PCINT7(can be seen in chapter about i/o ports). So id have to enable PCIE0 in PCIRC register, correct mask it TMSK0. and use ISR(PCINT0_vect). But if you have interrupt on PCINT6 and PCINT7 , you need if else in ISR to determine which of 2 pins triggered interrupt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM