Skip to content

Ticker::active() crashes when it call before attach_ms() #6511

@GitNik1

Description

@GitNik1

Board

ESP32 Dev Module

Device Description

Custom

Hardware Configuration

Version

latest master

IDE Name

VisualMicro

Operating System

Windows 10

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

115200

Description

_timer in Ticker lib is null before you call a attach methode and crashes in esp_timer_is_active(_timer);

Sketch

#include <Arduino.h>
#include <Ticker.h>

// attach a LED to GPIO 21
#define LED_PIN 2

Ticker tickerSetHigh;
Ticker tickerSetLow;

void setPin(int state) {
	digitalWrite(LED_PIN, state);
}

void setup() {
	pinMode(LED_PIN, OUTPUT);
	digitalWrite(1, LOW);

	bool isActive = tickerSetLow.active();
	// every 25 ms, call setPin(0) 
	tickerSetLow.attach_ms(25, setPin, 0);

	// every 26 ms, call setPin(1)
	tickerSetHigh.attach_ms(26, setPin, 1);
}

void loop() {

}

Debug Message

rst:0xc (SW_CPU_RESET),boot:0x3f (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:12812
load:0x40080400,len:3032
entry 0x400805e4
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x400e966b  PS      : 0x00060030  A0      : 0x800d0f18  A1      : 0x3ffb27c0  
A2      : 0x00000000  A3      : 0x00000000  A4      : 0x00000000  A5      : 0x00000004  
A6      : 0x00000028  A7      : 0x00000001  A8      : 0x00000002  A9      : 0x3ff44000  
A10     : 0x0000001f  A11     : 0x00000001  A12     : 0x00000001  A13     : 0x00000020  
A14     : 0x3ffc156c  A15     : 0x3ffc156c  SAR     : 0x0000001f  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  


Backtrace:0x400e9668:0x3ffb27c00x400d0f15:0x3ffb27e0 0x400d0e4c:0x3ffb2800 0x400d1252:0x3ffb2820

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: SolvedThe issue has been resolved and requires no further action.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions