Problems during Debugging with Interrupts

Hello,

I opened a new case as I have problems with Debugging the MQTT sample project on an ATMEGA 2560 with
added Interrupts. When producing a breakpoint in the IRQ routine debugging is paused and go ahead if the breakpoint
is removed. Are there any limitations when using IRQ routines, have there made some additional setings in the
platformio.io? All serial.prints are commented as suggested in the docs.

If a breakpoint is set during RUN an error message appears:
“Unable to get thread information: Cannot execute this command while the target is running.
Use the “interrupt” command to stop the target and then try again. (from thread-list-ids)”
What does this mean?

#include <Arduino.h>
#include <Ethernet.h>
#include <MQTT.h>
#include "avr8-stub.h"
#include "app_api.h"
#define timer_2000ms_val 20u
const unsigned char DO_TESTPIN = 53;
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
byte ip[] = {192, 168, 1, 177};  // <- change to match your network
EthernetClient net;
MQTTClient client;
unsigned long lastMillis = 0;
unsigned int timer_2000ms = timer_2000ms_val;
unsigned char testpin_toggle;

void do_2000ms(void)
{
  testpin_toggle ^= 1;
  if(testpin_toggle==1u)
  {
    digitalWrite(DO_TESTPIN, LOW);
  }else{
    digitalWrite(DO_TESTPIN, HIGH);
  }
}

void connect() {
  //Serial.print("connecting...");
  while (!client.connect("arduino", "public", "public")) {
    //Serial.print(".");
    //delay(1000);
  }
  //Serial.println("\nconnected!");
  client.subscribe("/hello");
  // client.unsubscribe("/hello");
}

void messageReceived(String &topic, String &payload) {
  //Serial.println("incoming: " + topic + " - " + payload);
  // Note: Do not use the client in the callback to publish, subscribe or
  // unsubscribe as it may cause deadlocks when other things arrive while
  // sending and receiving acknowledgments. Instead, change a global variable,
  // or push to a queue and handle it in the loop after calling `client.loop()`.
}

void setup() {
  debug_init();
   // timer init
  // cli();
  // Pin change IRQ control register
  // X X X X X PCIE2 PCIE1 PCIE0
  PCICR |= 0b00000100;  
  PCMSK0 |= 0b00000000;
  PCMSK1 |= 0b00000000;
  PCMSK2 |= 0b00001111;
  DDRK = 0x00;   // Port K as INPUT (1 = OUTPUT)
  PORTK = 0xFF;  // pullup enable
   #define PRESCALE0_1 1u
  #define PRESCALE0_8 2u
  #define PRESCALE0_64 3u
  #define PRESCALE0_256 4u
  #define PRESCALE0_1024 5u
  //set 16bit timer5 interrupt at 2kHz ISR(TIMER5_COMPA_vect)
  TCCR5A = 0; // set entire TCCR2A register to 0
  TCCR5B = 0; // same for TCCR2B
  TCNT5  = 0; //initialize counter value to 0
  // set compare match register for 1ms
  OCR5A = 0x0800;
  // turn on CTC mode
  TCCR5B |= (1 << WGM52);
  TCCR5B |= PRESCALE0_8;
  // enable timer compare interrupt
  TIMSK5 |= (1 << OCIE5A);
   //set 16bit Timer1 PhaseCorrect-PWM
  TCCR1A = 0u;
  TCCR1B = 0u;
  TCCR1A |= (1 << WGM11)|(1 << COM1A1);
  TCCR1B |= (1 << WGM13)|(1 << WGM12);
  OCR1A = 120u;
  ICR1 = 256u;
  TCCR1B |= PRESCALE0_64;
  //sei();//allow interrupts
  pinMode(DO_TESTPIN, OUTPUT);
   //Serial.begin(115200);
  Ethernet.begin(mac, ip);
  // Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
  // by Arduino. You need to set the IP address directly.
  client.begin("192.168.1.120", net);
  client.onMessage(messageReceived);
  connect();
}

//timer5 interrupt 2kHz
ISR(TIMER5_COMPA_vect)
{
  // Timer 2000ms
  if (--timer_2000ms == 0)
  {
    timer_2000ms = 500u;
    do_2000ms();
  }
}

void loop() {
  client.loop();
  if (!client.connected()) {
    connect();
  }
  // publish a message roughly every second.
  if (millis() - lastMillis > 10000) {
    lastMillis = millis();
    client.publish("/hello", "world");
  }
}

Kind regards
Mario

The documentation’s page 14, second “con” point in the “RAM breakpoints” section may apply to you depending on the used platformio.ini options?