0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

STM32G031のタイマー割り込みで遊ぶ

Last updated at Posted at 2022-04-28

目的
オリジナルI2C超音波距離センターからの値の取得に使う

leafonyさんのページより引用

o_con362.jpg

参考

STM32 MCU の Arduino IDE 設定

TM32F103 + Arduino_STM32 で タイマー




#include <Arduino.h>

#define LOOP_INTERVAL 150000
#define BOARD_LED_PIN PA11

HardwareTimer *timer2 = new HardwareTimer (TIM2);

void setup() {
    pinMode(BOARD_LED_PIN, OUTPUT);
    
  timer2->setOverflow(LOOP_INTERVAL, MICROSEC_FORMAT);       // 125ms
  timer2->attachInterrupt(intTimer);
  timer2->resume();
  
}

void loop(){

//handler_led();

delay(500);

}

void intTimer(void){
  
    static int LEDstate = 0;
    digitalWrite( BOARD_LED_PIN,LEDstate);
    if ( 0 < LEDstate )
    { LEDstate = 0; } else { LEDstate = 1; }

}




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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?