Skip to content

minor issues in core_esp8266_waveform.h #7703

Closed
@konohh

Description

@konohh
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).

Platform

  • Hardware: [ESP-12]
  • Core Version: [latest git]
  • Development Env: [Arduino IDE]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Generic ESP8266 Module|Wemos D1 mini r2]

Problem Description

core_esp8266_waveform.h

For my recent project I needed a (relatively precise) timer controlled trigger for my ISR function and I found it in the above mentioned part of the ESP core. I got it eventually working, nevertheless there are two minor issues I would like to address.

  1. It is documented in the "core_esp8266_waveform.h" that the CB function (set by "setTimer1Callback()") should return a value in microseconds (to set the time for the next call). This is not correct, the CB function must return the clock cycles to the next call. (Which as such is fine and absolutely correct).
  2. As the CB function is called in an Interrupt, the CB function has to be assigned with the ICACHE_RAM_ATTR attribute. To calculate the clock cycles to be returned by the CB function it may be essential to get the actual clock cycles. As per documentation this shall be done by calling "ESP.getClockCycles()". As far as I could figure it out, this function does not carry the ICACHE_RAM_ATTR attribute and therefore using it in an interrupt, the code crashes. Surely because of that issue, in the "core_esp8266_waveform.cpp" an inline function "GetCycleCount()" with the attribute ICACHE_RAM_ATTR is implemented and used. This "GetCycleCount()" function should be documented, prototyped and made available in the "core_esp8266_waveform.h" file.

Please bear with me, I'm not a software guy. If some of the above terms and definitions are not the correct ones… Sorry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions