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?
c avr
add a comment |
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?
c avr
You shouldn't take highlighting too seriously, and it's especially hard to answer any questions about highlighting if you don't even tell us what IDE you are using. Did you try compiling code? Was there an error? Can you post a Minimal, Complete, and Verifiable example? Did you check the ATmega328PB datasheet to see what interrupt vectors exist?
– David Grayson
Nov 16 '18 at 7:24
@DavidGrayson yeh my first time on overflow i should have been more detailed .I found the answer tho!
– l.leo
Nov 17 '18 at 8:56
add a comment |
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?
c avr
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?
c avr
c avr
asked Nov 15 '18 at 17:39
l.leol.leo
63
63
You shouldn't take highlighting too seriously, and it's especially hard to answer any questions about highlighting if you don't even tell us what IDE you are using. Did you try compiling code? Was there an error? Can you post a Minimal, Complete, and Verifiable example? Did you check the ATmega328PB datasheet to see what interrupt vectors exist?
– David Grayson
Nov 16 '18 at 7:24
@DavidGrayson yeh my first time on overflow i should have been more detailed .I found the answer tho!
– l.leo
Nov 17 '18 at 8:56
add a comment |
You shouldn't take highlighting too seriously, and it's especially hard to answer any questions about highlighting if you don't even tell us what IDE you are using. Did you try compiling code? Was there an error? Can you post a Minimal, Complete, and Verifiable example? Did you check the ATmega328PB datasheet to see what interrupt vectors exist?
– David Grayson
Nov 16 '18 at 7:24
@DavidGrayson yeh my first time on overflow i should have been more detailed .I found the answer tho!
– l.leo
Nov 17 '18 at 8:56
You shouldn't take highlighting too seriously, and it's especially hard to answer any questions about highlighting if you don't even tell us what IDE you are using. Did you try compiling code? Was there an error? Can you post a Minimal, Complete, and Verifiable example? Did you check the ATmega328PB datasheet to see what interrupt vectors exist?
– David Grayson
Nov 16 '18 at 7:24
You shouldn't take highlighting too seriously, and it's especially hard to answer any questions about highlighting if you don't even tell us what IDE you are using. Did you try compiling code? Was there an error? Can you post a Minimal, Complete, and Verifiable example? Did you check the ATmega328PB datasheet to see what interrupt vectors exist?
– David Grayson
Nov 16 '18 at 7:24
@DavidGrayson yeh my first time on overflow i should have been more detailed .I found the answer tho!
– l.leo
Nov 17 '18 at 8:56
@DavidGrayson yeh my first time on overflow i should have been more detailed .I found the answer tho!
– l.leo
Nov 17 '18 at 8:56
add a comment |
1 Answer
1
active
oldest
votes
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
There are two vectors for individual pinsINT0forPD2andINT1forPD3. It can be configured to detect falling edge, rising edge or low level. Pin change interrupts detects only the change and they have one ISR per port. And on bigger MCUs like Atmega256 pin change interrupts are not available on all ports (just four of them if I recall it correctly)
– KIIV
Nov 23 '18 at 8:43
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53325105%2fcan-i-use-pcint0-and-pcint1-for-all-pin-interrupts-on-atmega328pb%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
There are two vectors for individual pinsINT0forPD2andINT1forPD3. It can be configured to detect falling edge, rising edge or low level. Pin change interrupts detects only the change and they have one ISR per port. And on bigger MCUs like Atmega256 pin change interrupts are not available on all ports (just four of them if I recall it correctly)
– KIIV
Nov 23 '18 at 8:43
add a comment |
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
There are two vectors for individual pinsINT0forPD2andINT1forPD3. It can be configured to detect falling edge, rising edge or low level. Pin change interrupts detects only the change and they have one ISR per port. And on bigger MCUs like Atmega256 pin change interrupts are not available on all ports (just four of them if I recall it correctly)
– KIIV
Nov 23 '18 at 8:43
add a comment |
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
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
answered Nov 17 '18 at 9:10
l.leol.leo
63
63
There are two vectors for individual pinsINT0forPD2andINT1forPD3. It can be configured to detect falling edge, rising edge or low level. Pin change interrupts detects only the change and they have one ISR per port. And on bigger MCUs like Atmega256 pin change interrupts are not available on all ports (just four of them if I recall it correctly)
– KIIV
Nov 23 '18 at 8:43
add a comment |
There are two vectors for individual pinsINT0forPD2andINT1forPD3. It can be configured to detect falling edge, rising edge or low level. Pin change interrupts detects only the change and they have one ISR per port. And on bigger MCUs like Atmega256 pin change interrupts are not available on all ports (just four of them if I recall it correctly)
– KIIV
Nov 23 '18 at 8:43
There are two vectors for individual pins
INT0 for PD2 and INT1 for PD3. It can be configured to detect falling edge, rising edge or low level. Pin change interrupts detects only the change and they have one ISR per port. And on bigger MCUs like Atmega256 pin change interrupts are not available on all ports (just four of them if I recall it correctly)– KIIV
Nov 23 '18 at 8:43
There are two vectors for individual pins
INT0 for PD2 and INT1 for PD3. It can be configured to detect falling edge, rising edge or low level. Pin change interrupts detects only the change and they have one ISR per port. And on bigger MCUs like Atmega256 pin change interrupts are not available on all ports (just four of them if I recall it correctly)– KIIV
Nov 23 '18 at 8:43
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53325105%2fcan-i-use-pcint0-and-pcint1-for-all-pin-interrupts-on-atmega328pb%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You shouldn't take highlighting too seriously, and it's especially hard to answer any questions about highlighting if you don't even tell us what IDE you are using. Did you try compiling code? Was there an error? Can you post a Minimal, Complete, and Verifiable example? Did you check the ATmega328PB datasheet to see what interrupt vectors exist?
– David Grayson
Nov 16 '18 at 7:24
@DavidGrayson yeh my first time on overflow i should have been more detailed .I found the answer tho!
– l.leo
Nov 17 '18 at 8:56