Hello,
now deinstalled and after adding “debug_init();” to setup I received folloeing error:
Linking .pio\build\megaatmega2560\firmware.elf
HardwareSerial0.cpp.o (symbol from plugin): In function `Serial':
(.text+0x0): multiple definition of `__vector_25'
avr8-stub.c.o (symbol from plugin):(.text+0x0): first defined here
WInterrupts.c.o (symbol from plugin): In function `attachInterrupt':
(.text+0x0): multiple definition of `__vector_1'
avr8-stub.c.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\megaatmega2560\firmware.elf] Error 1
=============================================== [FAILED] Took 6.45 seconds ===============================================
* The terminal process "C:\Users\User\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
here the setup function, maybe you can tell me which interrupt is the problem, is it not allowed to use Serial.Print during debugging? I thought using another serial port is possible, for instance Serial3.
void setup()
{
// initialize GDB stub
debug_init();
cli();
// Pin change IRQ control register
// X X X X X PCIE2 PCIE1 PCIE0
PCICR |= 0b00000100;
// Pin Change Mask Register 0
// PCINT7 PCINT6 PCINT5 PCINT4 PCINT3 PCINT2 PCINT1 PCINT0
PCMSK0 |= 0b00000000;
// Pin Change Mask Register 0
// PCINT15 PCINT14 PCINT13 PCINT12 PCINT11 PCINT10 PCINT9 PCINT8
PCMSK1 |= 0b00000000;
// Pin Change Mask Register 0
// PCINT23 PCINT22 PCINT21 PCINT20 PCINT19 PCINT18 PCINT17 PCINT16
PCMSK2 |= 0b00001111;
DDRK = 0x00; // Port K as INPUT (1 = OUTPUT)
PORTK = 0xFF; // pullup enable
//set timer0 interrupt at 2kHz
TCCR0A = 0;// set entire TCCR2A register to 0
TCNT0 = 0;//initialize counter value to 0
// set compare match register for 2khz increments
OCR0A = 0x10;// = (16*10^6) / (200*64) - 1 8Bit register !!!
// turn on CTC mode
TCCR0A |= (1 << WGM01);
TIMSK0 |= (1 << OCIE0A);
sei();//allow interrupts
Serial3.begin(38400);
rxBufLen = 0u;
if(CAN0.begin(MCP_ANY, CAN_125KBPS, MCP_8MHZ) == CAN_OK)
Serial3.println("MCP2515 Initialized Successfully!");
else
Serial3.println("Error Initializing MCP2515...");
CAN0.setMode(MCP_NORMAL); // Set operation mode to normal so the MCP2515 sends acks to received data.
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(RELAIS1,HIGH);
digitalWrite(RELAIS2,HIGH);
digitalWrite(RELAIS3,HIGH);
.....
pinMode(DI_IRQ_MCP_CAN, INPUT); // Configuring pin for IRQ input Pin2
pinMode(DI_CheckFlimSwitch, INPUT); // Configuring pin
pinMode(DI_Start, INPUT); // Configuring pin
pinMode(DI_Stop, INPUT); // Configuring pin
pinMode(DI_InPos1, INPUT); // Configuring pin
pinMode(DI_BoltOK_IN, INPUT); // Configuring pin
pinMode(DI_GearCount1, INPUT); // Configuring pin
pinMode(DI_GearCount2, INPUT); // Configuring pin
....
attachInterrupt(digitalPinToInterrupt(DI_IRQ_MCP_CAN), ext_IRQ0, FALLING);
attachInterrupt(digitalPinToInterrupt(DI_InPos1), ext_IRQ1, RISING);
attachInterrupt(digitalPinToInterrupt(DI_GearCount1), ext_IRQ4, RISING);
attachInterrupt(digitalPinToInterrupt(DI_ReferenzOK), ext_IRQ5, RISING);
pciSetup(7);
pciSetup(8);
pciSetup(9);
pciSetup(A0);
Serial3.println("MCP2515 Library Receive Example...");
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial3.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
display.display();
delay(2000); // Pause for 2 seconds
// Clear the buffer
display.clearDisplay();
myservo0.attach(9); // attaches the servo on pin 9/10 to the servo object
myservo0.write(0); //0..180
myservo1.attach(10); // attaches the servo on pin 9/10 to the servo object
myservo1.write(0); //0..180
canbusRecv = 0;
ptxBuf=txBuf;
FYNcontr.Bitcountbyte = 8u;
Serial3.println("Timer ready...");
wdt_enable(WDTO_1S);
Serial3.println("Watchdog ready...");
}