LoginSignup
0
0

STM32C011の割り込みタイマーで遊ぶ(STM32C011J4M7)

Posted at

目的
割り込みタイマーのテスト
なんで動いたのかは、あまり理解していない
各自、勝手に調べてね!!

o_cop906.jpg




//GPIO_timer_interrupt_C011_1


//ヘッダー
#include <Arduino.h>


//定義
#define LOOP_INTERVAL 150000
#define BOARD_LED_PIN PA8

HardwareTimer *timer2 = new HardwareTimer (TIM1);


//初期化
void setup() {

  //ポートの初期化
  pinMode(BOARD_LED_PIN, OUTPUT);

  //割り込みタイマーの設定
  timer2->setOverflow(LOOP_INTERVAL, MICROSEC_FORMAT);       // 125ms
  timer2->attachInterrupt(intTimer);
  timer2->resume();

} //setup


//メインループ
void loop() {

  delay(500); //0.5秒待つ

} //loop


//割り込み
void intTimer(void) {

  //LEDの反転
  static int LEDstate = 0;
  digitalWrite( BOARD_LED_PIN, LEDstate);
  if ( 0 < LEDstate )
  {
    LEDstate = 0;
  } else {
    LEDstate = 1;
  }

} //intTimer



0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0