Hi everyone,
I need to declare 3 interrupts in my firmware
1 - on pin P1S1
2 - on pin P1S2
3 - on pin TX (#64)
The first two interrupt are working well, but when I tried to add the 3rd interrupt, it caused to a hard fault.
I am pretty sure that it’s not related to syntax because I used interrupts before and it worked well.
maybe it’s related to this pice information in the particle reference:
Fan.h:
#include "Particle.h"
#define FAN_PIN RX
#define FAN_TACHO TX
#define INIT_FAN_VALUE 255 //off
class Fan
{
private:
uint8_t fanSpeed;
void ISRfunc();
public:
Fan();
void setup();
void run();
void run(uint8_t);
void setFanSpeed(uint8_t);
};
Fan.cpp:
#include "Fan.h"
Fan::Fan()
{
this->setFanSpeed(INIT_FAN_VALUE);
}
void Fan::setup()
{
pinMode(FAN_PIN, OUTPUT);
this->run();
pinMode(FAN_TACHO, INPUT);
attachInterrupt(FAN_TACHO, &Fan::ISRfunc, this, CHANGE);
}
void Fan::run()
{
analogWrite(FAN_PIN, this->fanSpeed);
}
void Fan::run(uint8_t fanSpeed)
{
if (fanSpeed > 255 || fanSpeed < 0)
{
return;
}
analogWrite(FAN_PIN, fanSpeed);
}
void Fan::setFanSpeed(uint8_t fanSpeed)
{
if (fanSpeed <= 255 || fanSpeed >= 0)
{
this->fanSpeed = fanSpeed;
}
}
void Fan::ISRfunc()
{
Particle.publish("test", "*#*#*#*");
delay(200);
}
I hope that someone can help me with this issue soon.
Thanks in advance,
Omri