Skip to content

Commit

Permalink
Use DRAM for ESP32 protocol list (#352)
Browse files Browse the repository at this point in the history
And replace ICACHE_RAM_ATTR by IRAM_ATTR for ESP32, so as to avoir core dump when using in conjunction with Wifi
1technophile/OpenMQTTGateway#620
  • Loading branch information
1technophile authored Jun 21, 2020
1 parent bd0d2d5 commit ebe9171
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions RCSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@
#define memcpy_P(dest, src, num) memcpy((dest), (src), (num))
#endif

#if defined(ESP8266) || defined(ESP32)
#if defined(ESP8266)
// interrupt handler and related code must be in RAM on ESP8266,
// according to issue #46.
#define RECEIVE_ATTR ICACHE_RAM_ATTR
#define VAR_ISR_ATTR
#elif defined(ESP32)
#define RECEIVE_ATTR IRAM_ATTR
#define VAR_ISR_ATTR DRAM_ATTR
#else
#define RECEIVE_ATTR
#define VAR_ISR_ATTR
#endif


Expand All @@ -70,7 +75,7 @@
* These are combined to form Tri-State bits when sending or receiving codes.
*/
#if defined(ESP8266) || defined(ESP32)
static const RCSwitch::Protocol proto[] = {
static const VAR_ISR_ATTR RCSwitch::Protocol proto[] = {
#else
static const RCSwitch::Protocol PROGMEM proto[] = {
#endif
Expand Down

2 comments on commit ebe9171

@rogercortin
Copy link

@rogercortin rogercortin commented on ebe9171 Jul 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @1technophile, friend, I have been looking for a library for ESP32 for a long time that works properly with an RF 433 module. I found the RCSwitch.h library that seemed promising. However, even with the change suggested by the friend, the module still didn't work. There was also no error on the console. I'm a novice and I don't have the knowledge to solve it myself. Could you tell me if this suggested change worked on your equipment, what version of your esp, gpio, in short, anything that helps me find the cause of the failure. Thank you!

My software

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {

Serial.begin(115200);

mySwitch.enableReceive(34);

Serial.println("Setup realizado!");

}

void loop() {

if(mySwitch.available()) {

Serial.println("Escutando!");

int value = mySwitch.getReceivedValue();

if(value == 0) {
  Serial.println("Codificação não reconhecida");
}else {

  Serial.print("Recebido ");
  Serial.print(mySwitch.getReceivedValue());
  Serial.print(" / ");
  Serial.print(mySwitch.getReceivedBitlength());
  Serial.print("bit ");
  Serial.print("Protocolo: ");
  Serial.println(mySwitch.getReceivedProtocol());
  
}

}

}

@1technophile
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello, try to use gpio 27 or 26 for the receiver.
Please do not comment on a commit unless you are sure it is related to your issue.
Just open a new issue.

Please sign in to comment.