LoginSignup
0
0

More than 5 years have passed since last update.

DS1307.cpp:363:35: error: variable 'daysInMonth' must be const in order to be put into read-only section 発生

Last updated at Posted at 2018-10-08

 DS1307 使用時のコンパイルエラー対処・・覚書

sketch

コンパイルエラー(下記)

Arduino:1.8.7 (Windows 10), ボード:"Arduino/Genuino Uno"

ビルドオプションが変更されました。全体をリビルドしています。
In file included from d:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,

                 from sketch\I2Cdev.h:80,

                 from sketch\DS1307.h:37,

                 from sketch\DS1307.cpp:37:

sketch\DS1307.cpp:363:35: error: variable 'daysInMonth' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

     static uint8_t daysInMonth [] PROGMEM = { 31,28,31,30,31,30,31,31,30,31,30,31 };

                                   ^

exit status 1
ボードArduino/Genuino Unoに対するコンパイル時にエラーが発生しました。

「ファイル」メニューの「環境設定」から
「より詳細な情報を表示する:コンパイル」を有効にすると
より詳しい情報が表示されます。

Arduino 仕様変更

下記の通り修正

    //static uint8_t daysInMonth [] PROGMEM = { 31,28,31,30,31,30,31,31,30,31,30,31 };
    const uint8_t daysInMonth [] PROGMEM = { 31,28,31,30,31,30,31,31,30,31,30,31 };

ピン配置

1、Bat:バックアップ電圧(DS1307 3番ピン)
2、Gnd:GND
3、Vcc:VCC(5V)
4、Sda:SDA(I2C)
5、Scl:SCL(I2C)
6、DS :DS18B20 I/O
7、SQ :クロックパルス出力(1Hz、4.096kHz、8.192kHz、32.768kHz)

接続例(GND/VCC 以外)

Arduuino:A4 ⇔ SDA
Arduuino:A5 ⇔ SCL

実行結果

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