Hi,
I'm a german user and I apologize in advance for my english.
I have tried to programm a Timer funnction wich i outsourced in a .cpp.
Main Programm:
#include "Timer.h"
//*************************************************************************************//
//*** Hardware ***//
//** digital out **//
int i_led_1 = 26;
int i_led_2 = 27;
int i_pwm_neg = 32;
int i_pwm_pos = 33;
//** analog in **
int adc_cp = 4;
int i_read;
bool x_start = false;
bool x_out;
void setup() {
// set baud for return info
Serial.begin (115200);
analogReadResolution(12);
pinMode(i_led_1, OUTPUT);
pinMode(i_led_2, OUTPUT);
pinMode(i_pwm_neg, OUTPUT);
pinMode(i_pwm_pos, OUTPUT);
Timer_setup();
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(i_pwm_neg, LOW);
digitalWrite(i_pwm_pos, HIGH);
i_read = int( float(analogRead(adc_cp)) * 0.01 + float(i_read) * 0.99 ); // max 4095
Serial.println("Analogwert:" + String(i_read));
if (i_read < 2500 ) {
digitalWrite(i_led_1, HIGH);
x_start = true;
} else {
digitalWrite(i_led_1, LOW);
x_start = false;
}
//******************************************
//*** Timer
Timer_fkt( 0, x_start, 10000, x_out);
//******************************************
if (x_out == true){
digitalWrite(i_led_2, HIGH);
} else {
digitalWrite(i_led_2, LOW);
}
}
Timer.cpp:
#include "Timer.h"
#include <Arduino.h>
//*** configuration ***
hw_timer_t *timer = NULL;
volatile unsigned long ul_cnt_time;
volatile bool x_blink_ca;
volatile bool x_cach_1;
volatile bool x_cach_2;
//******** ISR function ********
void IRAM_ATTR onTimer(){
ul_cnt_time = ul_cnt_time + 1; // count the milliseconds
x_blink_ca = ! x_blink_ca;
if ( ul_cnt_time > 4294800000 ) {
ul_cnt_time = 0;
}
Serial.println( "Timer läuft " );
}
//********** Setup *************
void Timer_setup(){
//*************************************************************************************
// set timer
//*************************************************************************************
// Use 1st timer of 4 (counted from zero).
// Set 80 divider for prescaler: Quarz 80MHz/80 = 1´000´000 tic/sec = 1000ns = 1us
// flag = true to count up
timer = timerBegin(0, 80, true);
// Attach onTimer function to our timer.
timerAttachInterrupt(timer, &onTimer, true);
// Set alarm to call onTimer function every second (value in microseconds).
// Repeat the alarm (third parameter)
timerAlarmWrite(timer, 1000 , true); // repead every 1ms
timerAlarmEnable(timer); // Timer enable
}
//******* main Function *******
void Timer_fkt( int FUNC, bool IN, int TIMMS, bool OUT) {
if ( TIMMS > 4294800000 ) {
TIMMS = 4294800000;
}
//*************************************************************************************
// set timer funktion
//*************************************************************************************
switch (FUNC) {
case 0: //TON
if (IN == false) {
OUT = false;
ul_cnt_time = 0;
} else if ( (IN == true) && (ul_cnt_time < TIMMS) ){
OUT = false;
} else if ( (IN == true) && (ul_cnt_time >= TIMMS) ){
OUT = true;
}
break;
case 1: //TOF
if (IN == false) {
OUT = false;
ul_cnt_time = 0;
x_cach_1 = false;
} else if ( IN == true ){
OUT = true;
ul_cnt_time = 0;
x_cach_1 = true;
} else if ( (IN == false) && (ul_cnt_time < TIMMS) && (x_cach_1 = true) ){
OUT = true;
} else if ( (IN == false) && (ul_cnt_time >= TIMMS) && (x_cach_1 = true) ){
OUT = false;
ul_cnt_time = 0;
x_cach_1 = false;
}
break;
case 2: //TP
if ( (IN == true) && (x_cach_2 == false) ){
x_cach_2 = true;
}
if ( (x_cach_2 == true) && (ul_cnt_time < TIMMS) ) {
OUT = true;
} else if ( (x_cach_2 == true) && (ul_cnt_time >= TIMMS) ) {
OUT = false;
x_cach_2 = false;
}
break;
case 3: //BLINK
if (IN == true) {
OUT = x_blink_ca;
} else {
OUT = false;
}
break;
}
//*************************************************************************************
}
Timer.h:
void Timer_fkt ( int, bool, int, bool );
void Timer_setup() ;
every time i get the same error:
Analogwert:112
Analogwert:148
Analogwert:184
Analogwert:220
Timer läuft
Analogwert:256
Analogwert:291
AnaloGuru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC : 0x40088946 PS : 0x00060e34 A0 : 0x80087d6b A1 : 0x3ffbea60
A2 : 0x3ffb81f0 A3 : 0x3ffb8074 A4 : 0x00000001 A5 : 0x00000001
A6 : 0x00060e23 A7 : 0x00000000 A8 : 0x3ffb8074 A9 : 0x3ffb8074
A10 : 0x00000018 A11 : 0x00000018 A12 : 0x00000001 A13 : 0x00000001
A14 : 0x00060e21 A15 : 0x00000000 SAR : 0x00000015 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffc
Core 1 was running in ISR context:
EPC1 : 0x4008726a EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x40088946
ELF file SHA256: 0000000000000000
Backtrace: 0x40088946:0x3ffbea60 0x40087d68:0x3ffbea80 0x4008639f:0x3ffbeaa0 0x400d2251:0x3ffbeae0 0x400d12b5:0x3ffbeb00 0x400d149e:0x3ffbeb20 0x400d1509:0x3ffbeb40 0x40080f26:0x3ffbeb60 0x4008119d:0x3ffbeb80 0x40083c5d:0x3ffbeba0 0x400d225d:0x3ffb1ef0 0x400d12b5:0x3ffb1f10 0x400d14cd:0x3ffb1f30 0x400d14f1:0x3ffb1f50 0x400d0fbd:0x3ffb1f70 0x400d26e1:0x3ffb1fb0 0x40086565:0x3ffb1fd0
Core 0 register dump:
PC : 0x40087272 PS : 0x00060034 A0 : 0x80087a31 A1 : 0x3ffbe520
A2 : 0x3ffbdf84 A3 : 0x0000cdcd A4 : 0xb33fffff A5 : 0x00000001
A6 : 0x00060021 A7 : 0x0000abab A8 : 0x0000cdcd A9 : 0x3ffc00d8
A10 : 0x00000003 A11 : 0x00060023 A12 : 0x00060021 A13 : 0x3ffbc1b0
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000001f EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000
Backtrace: 0x40087272:0x3ffbe520 0x40087a2e:0x3ffbe550 0x4008664f:0x3ffbe570 0x400887c9:0x3ffbe590 0x40083c66:0x3ffbe5a0 0x400eb1f7:0x3ffbc130 0x400e1cf3:0x3ffbc150 0x400879fa:0x3ffbc170 0x40086565:0x3ffbc190
Rebooting...
ets Jul 29 2019 12:21:46
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, 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:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:10944
load:0x40080400,len:6388
entry 0x400806b4
Analogwert:38
Analogwert:75
Analogwert:112
Analogwert:149
Analogwert:185
Analogwert:221
Timer läuft
Analogwert:257
Analogwert:292
AnaloGuru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC : 0x40088946 PS : 0x00060e34 A0 : 0x80087d6b A1 : 0x3ffbea60
A2 : 0x3ffb81f0 A3 : 0x3ffb8074 A4 : 0x00000001 A5 : 0x00000001
A6 : 0x00060e23 A7 : 0x00000000 A8 : 0x3ffb8074 A9 : 0x3ffb8074
A10 : 0x00000018 A11 : 0x00000018 A12 : 0x00000001 A13 : 0x00000001
A14 : 0x00060e21 A15 : 0x00000000 SAR : 0x00000015 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffc
Core 1 was running in ISR context:
EPC1 : 0x4008726a EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x40088946
ELF file SHA256: 0000000000000000
Backtrace: 0x40088946:0x3ffbea60 0x40087d68:0x3ffbea80 0x4008639f:0x3ffbeaa0 0x400d2251:0x3ffbeae0 0x400d12b5:0x3ffbeb00 0x400d149e:0x3ffbeb20 0x400d1509:0x3ffbeb40 0x40080f26:0x3ffbeb60 0x4008119d:0x3ffbeb80 0x40083c5d:0x3ffbeba0 0x400d2262:0x3ffb1ef0 0x400d12b5:0x3ffb1f10 0x400d14cd:0x3ffb1f30 0x400d14f1:0x3ffb1f50 0x400d0fbd:0x3ffb1f70 0x400d26e1:0x3ffb1fb0 0x40086565:0x3ffb1fd0
Core 0 register dump:
PC : 0x40087272 PS : 0x00060034 A0 : 0x80087a31 A1 : 0x3ffbe520
A2 : 0x3ffbdf84 A3 : 0x0000cdcd A4 : 0xb33fffff A5 : 0x00000001
A6 : 0x00060021 A7 : 0x0000abab A8 : 0x0000cdcd A9 : 0x3ffc00d8
A10 : 0x00000003 A11 : 0x00060023 A12 : 0x00060021 A13 : 0x3ffbc1b0
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000001f EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000
Backtrace: 0x40087272:0x3ffbe520 0x40087a2e:0x3ffbe550 0x4008664f:0x3ffbe570 0x400887c9:0x3ffbe590 0x40083c66:0x3ffbe5a0 0x400eb1f7:0x3ffbc130 0x400e1cf3:0x3ffbc150 0x400879fa:0x3ffbc170 0x40086565:0x3ffbc190
Rebooting...
ets Jul 29 2019 12:21:46
Exception Decoder:
PC: 0x40088946: vListInsert at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/list.c line 188
EXCVADDR: 0x00000000
Decoding stack results
0x40088946: vListInsert at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/list.c line 188
0x40087d68: vTaskPlaceOnEventList at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 2901
0x4008639f: xQueueGenericReceive at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c line 1590
0x400d2251: uartWriteBuf at C:\Users\tomgs\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\esp32-hal-uart.c line 363
0x400d12b5: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\tomgs\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\HardwareSerial.cpp line 175
0x400d149e: Print::write(char const*) at C:\Users\tomgs\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h line 67
0x400d1509: Print::println(char const*) at C:\Users\tomgs\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\Print.cpp line 89
0x40080f26: onTimer() at C:\Users\tomgs\iCloudDrive\Firma\ESP32\Probe-Test\Test_10_timer/Timer.cpp.ino line 27
0x4008119d: __timerISR at C:\Users\tomgs\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\esp32-hal-timer.c line 88
0x400d225d: uartWriteBuf at C:\Users\tomgs\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\esp32-hal-uart.c line 365
0x400d12b5: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\tomgs\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\HardwareSerial.cpp line 175
0x400d14cd: Print::print(String const&) at C:\Users\tomgs\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h line 72
0x400d14f1: Print::println(String const&) at C:\Users\tomgs\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\Print.cpp line 188
0x400d0fbd: loop() at C:\Users\tomgs\iCloudDrive\Firma\ESP32\Probe-Test\Test_10_timer/Test_10_timer.ino line 36
0x400d26e1: loopTask(void*) at C:\Users\tomgs\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\main.cpp line 23
0x40086565: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143