日時 | |
関係者(共同研究者) | |
ESP8266には,タイマーが3つ搭載されているようある.その1つのtimer1は,23bit CountDown Timerになっている(https://github.c…).すなわち,2の23乗-1の値までタイマーに指定できる.さらに,プリスケーラは,1, 16, 256が搭載されている.基本クロックは,CPUのクロック周波数80MHzを基準にしているようである.タイマーの最大値は,プリスケーラを256にしたときに,約26.8秒となる.それ以上は,timer2割り込みが使えそうであるが,その関数は,まだ見つかっていない.なお,timer2は,32bit CountUp Timerになっている.
ライブラリーのクラス↓
https://github.c…
サンプルコード↓
https://github.c…
以下,ヘッダーファイルから抜粋↓
https://github.c…
//timer dividers
#define TIM_DIV1 0 //80MHz (80 ticks/us - 104857.588 us max)
#define TIM_DIV16 1 //5MHz (5 ticks/us - 1677721.4 us max)
#define TIM_DIV265 3 //312.5Khz (1 tick = 3.2us - 26843542.4 us max)
//timer int_types
#define TIM_EDGE 0
#define TIM_LEVEL 1
//timer reload values
#define TIM_SINGLE 0 //on interrupt routine you need to write a new value to start the timer again
#define TIM_LOOP 1 //on interrupt the counter will start with the same value again
#define timer1_read() (T1V)
#define timer1_enabled() ((T1C & (1 << TCTE)) != 0)
#define timer1_interrupted() ((T1C & (1 << TCIS)) != 0)
typedef void(*timercallback)(void);
void timer1_isr_init(void);
void timer1_enable(uint8_t divider, uint8_t int_type, uint8_t reload);
void timer1_disable(void);
void timer1_attachInterrupt(timercallback userFunc);
void timer1_detachInterrupt(void);
void timer1_write(uint32_t ticks); //maximum ticks 8388607
関連: Nefry