Hello all, im pretty new in Arduino world.
For my current project i am using custom samd11d14AM board and FAB arduino Mattiartech library.
I use TPL5010 watchdog. Resistors are set for 1s.
i am trying to perform high priority interrupt on pin PA14
and want to read WAKE signal and reset . My code turn on/off via pwm buzzer and this task take around 600mS. Beeep-bep-bep. The problem is that samd11 constantly reset when i send commands via terminal, this mean external WDT constantly reset it.
So, just software check Wake signal not do the job, i need interrupt reading.
//Define MCU pins
int DONE = 15;
int WAKE = 14;
int BUZ1 = 16;
int BUZ2 = 17;
int LED = 10;
bool running = false;
unsigned long startMillis;
unsigned long currentMillis;
const unsigned long period = 10000;
void task_on(void) {
delay(300);
analogWrite(BUZ1, 130);
analogWrite(BUZ2, 130);
digitalWrite(LED, HIGH);
delay(250);
analogWrite(BUZ1, 0);
analogWrite(BUZ2, 0);
digitalWrite(LED, LOW);
delay(150);
analogWrite(BUZ1, 130);
analogWrite(BUZ2, 130);
digitalWrite(LED, HIGH);
delay(45);
analogWrite(BUZ1, 0);
analogWrite(BUZ2, 0);
digitalWrite(LED, LOW);
delay(45);
analogWrite(BUZ1, 130);
analogWrite(BUZ2, 130);
digitalWrite(LED, HIGH);
delay(45);
analogWrite(BUZ1, 0);
analogWrite(BUZ2, 0);
digitalWrite(LED, LOW);
delay(45);
analogWrite(BUZ1, 130);
analogWrite(BUZ2, 130);
digitalWrite(LED, HIGH);
delay(45);
analogWrite(BUZ1, 0);
analogWrite(BUZ2, 0);
digitalWrite(LED, LOW);
delay(45);
analogWrite(BUZ1, 130);
analogWrite(BUZ2, 130);
digitalWrite(LED, HIGH);
delay(45);
analogWrite(BUZ1, 0);
analogWrite(BUZ2, 0);
digitalWrite(LED, LOW);
delay(45);
};
void task_off(void) {
analogWrite(BUZ1, 0);
analogWrite(BUZ2, 0);
digitalWrite(LED, LOW);
};
void setup() {
// // put your setup code here, to run once:
Serial.begin(9600);
Serial.setTimeout(10);
while (!Serial);
startMillis = millis(); //initial start time
// // //Start External Watchdog
pinMode(DONE, OUTPUT);
pinMode(WAKE, INPUT_PULLDOWN);
pinMode(LED, OUTPUT);
task_off();
digitalWrite(DONE, HIGH);
delayMicroseconds(20);
digitalWrite(DONE, LOW);
Serial.println("beat");
}
void loop()
{
if (digitalRead(WAKE)==1)
{
digitalWrite(DONE, HIGH);
delayMicroseconds(20);
digitalWrite(DONE, LOW);
}
currentMillis = millis();
//get the current "time" (actually the number of milliseconds since the program started)
if (currentMillis - startMillis >= period) //test whether the period has elapsed
{
Serial.println("beat");
startMillis = currentMillis; //IMPORTANT to save the start time of the current LED state.
}
if (Serial.available() > 0)
{
String str = Serial.readString();
if (str == "helloknockknock")
{
Serial.println("hellofromknockknock");
}
if (str == "ON") {
running = true;
} else if (str == "OFF") {
running = false;
}
}
if (running == true) {
task_on();
} else task_off();
}