タグ

avr-libcに関するhatayanorgのブックマーク (2)

  • 橋本商会 » ATmega168でピン変化割り込み

    ATmega88以降は全てのI/Oピンに「外部入力割り込み」が付いている。これは、それぞれのピンに電流がONになったり、OFFになったりするとイベントが起こるという事だ。 今まではmain()の中のループで各ピンをずっと監視し続けなければならなかったが、この外部入力ピンを使うと完全にイベントドリブンでプログラムを書ける様になる。ちなみにArduinoからは使えない機能です。 ■作った PB1につながったスイッチを押した時に割り込み(SIG_PIN_CHANGE0)が発生し、UARTでPCに通知する。PB0のLEDも光らせる。スイッチを離すとLEDを消し、UARTで通知する。 SourceCode, hex, Makefile(avr-gcc 3.4.6) ■外部入力割り込みの仕組み 2箇所設定する必要がある。 1.「ピン変化割り込みレジスタ」でピン変化割り込みを許可する 2.入力割り込みを

    橋本商会 » ATmega168でピン変化割り込み
  • avr-libc: <avr/interrupt.h>: Interrupts

    Detailed Description NoteThis discussion of interrupts was originally taken from Rich Neswold's document. See Acknowledgments. Introduction to avr-libc's interrupt handling It's nearly impossible to find compilers that agree on how to handle interrupt code. Since the C language tries to stay away from machine dependent details, each compiler writer is forced to design their method of support. In t

    hatayanorg
    hatayanorg 2010/10/12
    [avr/interrupt.h]
  • 1