Program crashes, help.

I created this Atmel Studio 7 project by importing an arduino project.
Then I added some C libraries from another project (andy's LCD).

I removed the init function from main since I want to control the timers differently.

My program begins with the following code:
Serial.begin(115200);
Serial.println("TPUART2 Test");
knx.begin(Serial2, P_ADDR(1, 1, 1); //This is the imported libray, a knx arduino project.

If I remove the third line then the program executes, although not normally. First the "TP" is printed in the serial port and after about a second, the program runs normaly.

When I include the third line, the knx.begin function, then the program crashes before returning from knx.begin.

More specifically, here are the first lines of knx.begin:
Serial.println("here 1\n");
_tpuart = new KnxTpUart(serial ,physicalAddr, NORMAL);
Serial.println("here 2\n");

The "here 1" string is always outputed.
The "here 2" string is nover outputed.

Inside the KnxTpUart function, I print a string just before the function returns and it is outputed!!

So, the problem occurs when returning from this function somehow, I have no idea.

Do you think it has something to do with this being a C++ function??

Any ideas?

Thanks,
Bill.

Unfortunately serial prints are not a very good way to detect where a program crashes. Serial communication takes time so the line that causes the crash may actually be after the print that didn't go through. You can add a delay after the serial print to give it enough time to go through.

The real problem I am facing throughout this project is that I cannot debug with my JTAG mkII.

I wanted to use this nice knx library that is written for arduino (although I thing it was developed in eclipse) so I migrated to Atmel studio 7.0 because Atme studi 6.2 was not accepting it correctly.

So now I am trying to develop something without a real debugger.

That sucks!

Thanks anyway.

I bought AVR ICE and it works fine.
So much for JTAG MKII.....