简体   繁体   English

是否可以将PCINT0和PCINT1用于atmega328pb上的所有引脚中断?

[英]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(这是波顿的针脚)LED点亮。 PINB7 is PCINT8 on board. 板上的PINB7是PCINT8。 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. 我没有在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? 从我所看到的,我应该只做PCINT8_vect,但是矢量不会像我使用“ TIMER2_COMPB_vect”那样突出显示。那么PCINT8矢量不存在或者有没有办法使用PCINT0和1?

Apparently , on mega328pb , there is no vectors for individual pin interrupts but there are vectors for PCIE0,1,2,3. 显然,在mega328pb上,没有用于单个引脚中断的向量,但是对于PCIE0、1、2、3有向量。 0- bits 0:7 1-8:14 2-16:23 3-24:27 0位0:7 1-8:14 2-16:23 3-24:27

so if u want to use interrupt for pin b7. 因此,如果您想对插针b7使用中断。 PB7 is PCINT7(can be seen in chapter about i/o ports). PB7是PCINT7(可以在关于I / O端口的章节中看到)。 So id have to enable PCIE0 in PCIRC register, correct mask it TMSK0. 因此,id必须在PCIRC寄存器中启用PCIE0,并将其正确屏蔽为TMSK0。 and use ISR(PCINT0_vect). 并使用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 但是,如果在PCINT6和PCINT7上有中断,则需要在ISR中是否需要确定2个引脚中的哪一个触发了中断

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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