Description
Basic Infos
Hardware
Hardware: ESP-12 & ESP-07
Core Version: 2.3.0
Description
Hi,
I want to generate 4uS square wave with 50% duty cycle and I use os_timer_arm_us function but that generate 4mS square wave same as os_timer_arm function!!
what is my mistake? Thank you
Settings in IDE
Module: Generic ESP8266 Module
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Mode: DIO
Flash Frequency: 40Mhz?
Upload Using: SERIAL
Reset Method: ck
Sketch
#define out_pin 5
volatile unsigned long timeSpent=1;
volatile int toggle;
unsigned long prevMillis=0;
unsigned long current_time=0;
extern "C" {
#define USE_US_TIMER
#include "user_interface.h"
#include "osapi.h"
#define os_timer_arm_us(a, b, c) ets_timer_arm_new(a, b, c, 0)
}
os_timer_t t0;
void myIsrTimer(void*z)
{
// current_time = micros();
// timeSpent = current_time - prevMillis;
// prevMillis = current_time;
toggle = (toggle == 1) ? 0 : 1;
digitalWrite(out_pin,toggle);
}
void setup() {
pinMode(out_pin, OUTPUT);
os_timer_setfn(&t0, myIsrTimer, NULL);
os_timer_arm_us(&t0, 4, true);
// Initialise Serial connection
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
//Serial.print(timeSpent);Serial.print(" ");
}