我有一个大师错误,当我试图编译和上传这段代码,这只是代码的一部分,但错误是在这一部分。
在模拟和我的esp 32开发工具包中,我得到了相同的错误!
#include <Arduino.h>
#include "esp_types.h"
#include <Wire.h>
#include <stdio.h>
#include <string.h>
#include <EEPROM.h>
#include <driver/ledc.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <BluetoothSerial.h>
#include <esp_task_wdt.h>
#define WATCHDOG_TIMOUT 30
#define MIN_SPEED_FAN 10 // In %
#define MAX_SPEED_FAN 100 // In %
#define INCRESE_STEP_SPEED 0.5 // In %
// Pins defines
#define LM_ADC 12
#define PRESSURE_ADC 35
#define PWM_FAN 13
#define OUT_HEATER 32
// Size of the data
#define DATA_SIZE 32
// Flash address
#define ADDR_REF_LM_VOL_1 0
#define ADDR_REF_LM_VOL_2 1
#define ADDR_REF_LM_VOL_3 2
#define ADDR_REF_LM_VOL_4 3
#define ADDR_PC_LOW_TEMP_1 5
#define ADDR_PC_LOW_TEMP_2 6
#define ADDR_PC_LOW_TEMP_3 7
#define ADDR_PC_LOW_TEMP_4 8
#define ADDR_PC_HIGH_TEMP_1 9
#define ADDR_PC_HIGH_TEMP_2 10
#define ADDR_PC_HIGH_TEMP_3 11
#define ADDR_PC_HIGH_TEMP_4 12
#define ADDR_PC_LOW_PRES_1 13
#define ADDR_PC_LOW_PRES_2 14
#define ADDR_PC_LOW_PRES_3 15
#define ADDR_PC_LOW_PRES_4 16
#define ADDR_PC_HIGH_PRES_1 17
#define ADDR_PC_HIGH_PRES_2 18
#define ADDR_PC_HIGH_PRES_3 19
#define ADDR_PC_HIGH_PRES_4 20
#define DELAY_READ 3000
// Create class bluetooth, to handle bluetooth comunication
BluetoothSerial SerialBT;
TaskHandle_t taskControleTemperaturaHandle;
void taskLeituraSensor(void *pvParameters);
//_________________________________________________________________________Lm_________________________________________________________________________
// Reference voltage input lm
int iLmRefMv;
int iTempLmRefMv[] = {0, 0, 0, 0};
// Readed value LM
int iLmValue;
// Mean LM reads
float fMeanLmRead;
// Value read in Milli volts
float fMilliVolts;
// Temperature un C
float fTempC;
//_________________________________________________________________________Pressure___________________________________________________________________
// Readed value of pression
int iPressureValue;
//Mean pressure reads
float fMeanPressureRead;
//_________________________________________________________________________Temperature Control___________________________________________________________________
// Lower point of control of the temperature, this value is in C and should be multiply be 100
int iLowPcTemp;
int iTempLowPcTemp[] = {0, 0, 0, 0};
// High point of control of the temperature, this value is in C and should be multiply be 100
int iHighPcTemp;
int iTempHighPcTemp[] = {0, 0, 0, 0};
// Rember if the temperature is below the PC low
int iRecordBelowPcRange = 0;
// Rember if the temperature is above the PC low
int iRecordAbovePcRange = 0;
//_________________________________________________________________________Pressure Control___________________________________________________________________
// Lower point of control of the temperature, this value is in C and should be multiply be 100
int iLowPcPress;
int iTempLowPcPress[] = {0, 0, 0, 0};
// High point of control of the temperature, this value is in C and should be multiply be 100
int iHighPcPress;
int iTempHighPcPress[] = {0, 0, 0, 0};
int iPwmFrequency = 500;
int iPwmResolution = 12;
int iPwmValue = 0;
//_________________________________________________________________________Qtd of reads_________________________________________________________________________
uint8_t uiQtdRead = 30;
//_________________________________________________________________________Bluetooth variables_________________________________________________________________________
String sReceivedData = "";
//_________________________________________________________________________Setup_________________________________________________________________________
void setup() {
// Serial comunicação com o PC
Serial.begin(115200);
//Serial Bluetooth
//SerialBT.begin("Termikas");
EEPROM.begin(DATA_SIZE);
EEPROM.get(ADDR_REF_LM_VOL_1, iTempLmRefMv[0]);
EEPROM.get(ADDR_REF_LM_VOL_2, iTempLmRefMv[1]);
EEPROM.get(ADDR_REF_LM_VOL_3, iTempLmRefMv[2]);
EEPROM.get(ADDR_REF_LM_VOL_4, iTempLmRefMv[3]);
iLmRefMv = (iTempLmRefMv[0] - 48) * 1000;
iLmRefMv += (iTempLmRefMv[1] - 48) * 100;
iLmRefMv += (iTempLmRefMv[2] - 48) * 10;
iLmRefMv += (iTempLmRefMv[3] - 48);
EEPROM.get(ADDR_PC_LOW_TEMP_1, iTempLowPcTemp[0]);
EEPROM.get(ADDR_PC_LOW_TEMP_2, iTempLowPcTemp[1]);
EEPROM.get(ADDR_PC_LOW_TEMP_3, iTempLowPcTemp[2]);
EEPROM.get(ADDR_PC_LOW_TEMP_4, iTempLowPcTemp[3]);
iLowPcTemp = (iTempLowPcTemp[0] - 48) * 1000;
iLowPcTemp += (iTempLowPcTemp[1] - 48) * 100;
iLowPcTemp += (iTempLowPcTemp[2] - 48) * 10;
iLowPcTemp += (iTempLowPcTemp[3] - 48);
EEPROM.get(ADDR_PC_HIGH_TEMP_1, iTempHighPcTemp[0]);
EEPROM.get(ADDR_PC_HIGH_TEMP_2, iTempHighPcTemp[1]);
EEPROM.get(ADDR_PC_HIGH_TEMP_3, iTempHighPcTemp[2]);
EEPROM.get(ADDR_PC_HIGH_TEMP_4, iTempHighPcTemp[3]);
iHighPcTemp = (iTempHighPcTemp[0] - 48) * 1000;
iHighPcTemp += (iTempHighPcTemp[1] - 48) * 100;
iHighPcTemp += (iTempHighPcTemp[2] - 48) * 10;
iHighPcTemp += (iTempHighPcTemp[3] - 48);
EEPROM.get(ADDR_PC_LOW_PRES_1, iTempLowPcPress[0]);
EEPROM.get(ADDR_PC_LOW_PRES_2, iTempLowPcPress[1]);
EEPROM.get(ADDR_PC_LOW_PRES_3, iTempLowPcPress[2]);
EEPROM.get(ADDR_PC_LOW_PRES_4, iTempLowPcPress[3]);
iLowPcPress = (iTempLowPcPress[0] - 48) * 1000;
iLowPcPress += (iTempLowPcPress[1] - 48) * 100;
iLowPcPress += (iTempLowPcPress[2] - 48) * 10;
iLowPcPress += (iTempLowPcPress[3] - 48);
EEPROM.get(ADDR_PC_HIGH_PRES_1, iTempHighPcPress[0]);
EEPROM.get(ADDR_PC_HIGH_PRES_2, iTempHighPcPress[1]);
EEPROM.get(ADDR_PC_HIGH_PRES_3, iTempHighPcPress[2]);
EEPROM.get(ADDR_PC_HIGH_PRES_4, iTempHighPcPress[3]);
iHighPcPress = (iTempHighPcPress[0] - 48) * 1000;
iHighPcPress += (iTempHighPcPress[1] - 48) * 100;
iHighPcPress += (iTempHighPcPress[2] - 48) * 10;
iHighPcPress += (iTempHighPcPress[3] - 48);
pinMode(PWM_FAN, OUTPUT);
pinMode(OUT_HEATER, OUTPUT);
ledcSetup(0, iPwmFrequency, iPwmResolution);
ledcAttachPin(PWM_FAN, 0);
//xTaskCreatePinnedToCore(taskControleTemperatura, "Controle aquecedores", 1024, NULL, 1, NULL, tskNO_AFFINITY);
//xTaskCreatePinnedToCore(taskControlePressao, "Controle Pressao", 1024, NULL, 2, NULL, tskNO_AFFINITY);
xTaskCreate(taskLeituraSensor, "lmRead", configMINIMAL_STACK_SIZE + 1024, NULL, 1, &taskControleTemperaturaHandle);
//xTaskCreatePinnedToCore(taskLeituraPressao, "Leitura do sensor de pressao", 1024, NULL, 19, NULL, tskNO_AFFINITY);
digitalWrite(OUT_HEATER, LOW);
}
void loop() {
for(int i = 0; i < 100000000; i++){
}
}
void taskLeituraSensor(void * pvParameters){
fTempC = 0;
Serial.println("In read");
/*for(int i = 0; i < uiQtdRead; i++){
iLmValue = analogRead(LM_ADC);
fMilliVolts = iLmValue * (iLmRefMv / 4096);
fTempC = fMilliVolts/10;
fMeanLmRead += fTempC;
}
Serial.println("afer for");
fTempC = fTempC / uiQtdRead;
Serial.println("afer fo22r");*/
vTaskDelay(pdMS_TO_TICKS(3000));
}
字符串
当一个向上这个代码到一个esp 32我有这个错误
Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x400d1fb4: e5f81fa1 f01dc1fe 22006136
Core 0 register dump:
PC : 0x400d1fba PS : 0x00060e30 A0 : 0x00000000 A1 : 0x3ffbb900
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x800d1fba A9 : 0x3ffbb8e0
A10 : 0x00000bb8 A11 : 0x3ffbf398 A12 : 0x00000014 A13 : 0x00000000
A14 : 0x3ffbd2d0 A15 : 0x80000001 SAR : 0x00000000 EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x4008f89d LEND : 0x4008f8ad LCOUNT : 0xfffffffd
Backtrace: 0x400d1fb7:0x3ffbb900
ELF file SHA256: d76f5191ead975b1
型
这只是代码的一部分,但问题就出在这方面!
使用exception解码器,我得到这个错误:
PC: 0x400d22dc
EXCVADDR: 0x00000000
Decoding stack results
0x400d22d9: TwoWire::TwoWire(unsigned char) at C:\Users\Dell-XPS\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.7\cores\esp32/Stream.h line 54
型
1条答案
按热度按时间bwitn5fc1#
您应该在
loop()
中使用延迟,而不是使用busy-wait循环。在该循环中,任何启用的看门狗都不会得到服务,并且任何较低/同等优先级的任务都将被阻止运行:字符串
我知道在ESP 32上的platformio中,
setup()
和loop()
本身运行在RTOS上下文中。您的
taskLeituraSensor()
运行到完成并返回-这不是任务函数的常见行为-通常任务在无限循环中运行。任务至少应删除自身以在终止时恢复资源:型
在任何情况下,如果任务在任何情况下简单地终止,则根本不清楚延迟的目的是什么。
更常见的任务结构是:
型
或者,如果任务打算在某个点终止:
型