Skip to content

os_timer_arm_us does not work truly #3724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
etoshey opened this issue Oct 16, 2017 · 1 comment
Closed

os_timer_arm_us does not work truly #3724

etoshey opened this issue Oct 16, 2017 · 1 comment

Comments

@etoshey
Copy link

etoshey commented Oct 16, 2017

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(" ");
}

Debug Messages

@etoshey etoshey changed the title os_timer_arm_us does notwork truly os_timer_arm_us does not work truly Oct 16, 2017
@devyte
Copy link
Collaborator

devyte commented Oct 20, 2017

@etoshey The referenced function is an Espressif SDK api, not an api offered by the core in this repo.
The Espressif SDK api referene for sdk 2.1.0, section 3.1.5, says the following about os_timer_arm_us():

void	os_timer_arm_us(os_timer_t *ptimer,
                                    uint32_t microseconds,
                                    bool repeat_flag)
os_timer_t *ptimer: timer structure. 
uint32_t microseconds: timing; unit: microsecond, the minimum value is 0x64, the maximum value allowed to input is 0xFFFFFFF. 
bool	repeat_flag: whether the timer will be invoked repeatedly or not. 

This is not the right place to ask such questions. This is an issue tracker, meant to track issues in the Arduino-like core libs. Please do your research, and if you need help, refer to a community forum.
Closing per #3655 .

@devyte devyte closed this as completed Oct 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants