LoginSignup
0
0

More than 1 year has passed since last update.

STM32F767で時間関数と繰り返しタイマー割込みで遊ぶ(1秒)

Posted at

目的
簡易な時間づくり
例題をほぼそのまま使用

o_con583.jpg

SER_time_test1_767_1



#include "mbed.h"

DigitalOut led(LED1);

Serial pc(SERIAL_TX, SERIAL_RX);

Ticker flipper;

time_t seconds = 0 + (60 * 60 * 9); // JST

void flip() {
    led = !led;
    seconds++;
}

int main()
{
    
    flipper.attach(&flip, 1.0); // the address of the function to be attached (flip) and the interval (1 seconds)

    
    pc.printf("\r\n<START>\r\n");
    
    
    struct tm *t;
    
    while(1) {
            
    t = localtime(&seconds);
 
    pc.printf("%04d/%02d/%02d %02d:%02d:%02d",
      t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
 
    pc.printf("\r\n");

        wait(1.0);
    }
}




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