Re: [問題] 如何在interrupt結束後要求program回到 …
謝謝littleshan的幫忙
我看了longjmp的用法,唯一會產生問題,似乎是
longjmp會Reset我的global variable counter;
所以我參考了http://0rz.tw/XAUZ1的建議
以下是我的code
/* counter -- +1 when user pressed PB9 */
register unsigned char counter asm("r3");
jmp_buf env;
int main() {
counter = 0;
setjmp(env);
for(;;){
.....
}
}
ISR(INT0_vect) {
if(counter >= 7) {
counter = 0;
} else {
counter++;
}
longjmp(env, 1);
}
在我program到我的Microcontroller之後,按下按鈕counter值仍然沒變
請各位大大幫個忙
十分感謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.241.116.21
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章