For some reason my Mega 2560 has started resetting when writing more than one character at a time to Serial1. Is there a way to trap automatic resets and export some kind of debug information before the reset completes?
No.... but it depends on what kind of reset it is.
Can you try Arduino 1.0.3 and 1.5.2 ?
Can you try with a (other) adapter ?
I don't know for fact what kind of reset is happening, but I suspect it's an error handler. Is there a way to vector an error handling IRQ to a custom function so it's details can be written to Serial?
You are thinking in a x86 way.
You can see the vector table in the "complete" datasheet: http://www.atmel.com/devices/atmega2560.aspx?tab=documents at page 105.
It is interrupts, timers, uart, and a reset vector. That's all.
plbyrd:
For some reason my Mega 2560 has started resetting when writing more than one character at a time to Serial1. Is there a way to trap automatic resets and export some kind of debug information before the reset completes?
This is a programming issue, not an installation one. I'll move it for you. Then we need to see your code.
Thanks to everyone for your responses. It was indeed a software issue. After chatting with some guys in #Arduino on FreeNode I discovered that I was clobbering the stack because I had too many strings in SRAM. I changed my strings to use the F() macro as well as changed how my class was being instantiated (moved all the code I had in the constructor to a begin() method) and now everything is happy again.
It would be nice if information like I picked up in #Arduino was more readily available. I've spent a lot of time reading the documentation from the main site and not once had encountered warnings about strings in SRAM and stuff like that.
plbyrd:
I've spent a lot of time reading the documentation from the main site and not once had encountered warnings about strings in SRAM and stuff like that.
Apart from the "sticky" right at the top of the "Programming Questions" section of this forum?
Read this before posting a programming question
Read point 8 about SRAM.
Also under "memory" in the Playground is mentioned the F macro.
http://playground.arduino.cc/Learning/Memory
I've updated the sticky to directly mention the F macro, as that is the sort of thing you probably don't realize exists, until someone tells you.