I created a simple test project for IRAM_ATTR as shown in the code below. I tried sending images or attachments which show the squiggles but apparently, it's not allowed.
Code 1: shows the IRAM_ATTR procedure placed after the pin was attached in the preceding setup procedure. The build failed because the IRAM_ATTR was not declared. D1, IRAM_ATTR and movementDetected have squiggles in the code why?
#include <Arduino.h>
const int movementPin = D1;
int movementCount = 0;
void setup()
{
pinMode(movementPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(movementPin), movementDetected, CHANGE);
}
void loop()
{
}
void IRAM_ATTR movementDetected() {
movementCount++;
}
Build Result:
IRAM_ATTR_Test.ino: 9:54: error: 'movementDetected' was not declared in this scope
9 | attachInterrupt(digitalPinToInterrupt(movementPin), movementDetected, CHANGE)
| ^~~~~~~~~~~~~~~~
Error compiling sketch sources
Build failed for project 'IRAM_ATTR_Test'
Code 2: I moved the IRAM_ATTR function above the setup procedure and the build was successful. In Arduino version 1.6/1.8 the IRAM_ATTR procedure could be placed after the attachInterrupt in the setup procedure. D1, IRAM_ATTR and movementDetected still have squiggles in the code?
#include <Arduino.h>
const int movementPin = D1;
int movementCount = 0;
void IRAM_ATTR movementDetected() {
movementCount++;
}
void setup()
{
pinMode(movementPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(movementPin), movementDetected, CHANGE);
}
void loop()
{
}
Build Result:
# Copy build result to 'Project>Property Pages>Intermediate Directory'
# Destination: 4/Release/"
║ SEGMENT BYTES DESCRIPTION
╚══ IROM 232036 code in flash
Code 3: Here I added a String and rebuilt the project, and it appears that I am still having issues with Intellisense. String does not show up in the Intellisense popup. D1, IRAM_ATTR, movementDetected and String have squiggles in the code?
#include <Arduino.h>
const int movementPin = D1;
int movementCount = 0;
String myStr = "";
void IRAM_ATTR movementDetected() {
movementCount++;
}
void setup()
{
pinMode(movementPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(movementPin), movementDetected, CHANGE);
}
void loop()
{
}
Build Result:
# Copy build result to 'Project>Property Pages>Intermediate Directory'
# Destination: 4/Release/"
Code in flash (default, ICACHE_FLASH_ATTR), used 232644 \ 1048576 bytes (22%)
║ SEGMENT BYTES DESCRIPTION
╚══ IROM 232644 code in flash
Any help would be appreciated because this is quite annoying dealing with Intellisense while writing code.
Thanks, Randy