I cannot use the Arduino wiring language. So instead I'm using another IDE (AVR Studio) and a batch file to have avrdude upload the hex file to my atmel2560.
During a recent upload, I had an LED blink rapidly and now it won't be programmed by avrdude or even the arduino IDE anymore. The connection times out and I feel as if it's stuck in this perpetual blinking state.
I want to manually erase the memory and factory restore it but I don't know how. Can anyone help me?
As you've told me in your PM that the board didn't pass the loop-back test I have my doubts.
Not passing said test indicates either (or both) of two things:
a) drivers don't work. Usually the board should show up as a new COM port in the device manager when plugged in (no yellow exclamation marks).
b) the usb chip is toast.
However, you can use an ISP + avrdude (or another arduino using ArduinoISP) to check if the main processor is still alive. If that is the case you can also use an ISP to upload new code. You need to make sure AVRStudio supports the programmer of course. If the usb chip is indeed toast, you may want to look for someone with a hot-air rework tool to replace it. People who own such a device shouldn't have any trouble with that chip. Depending on where you are, there might be an electronics club (or nowadays a hacker-space) near you.
My computer recognizes the device on COM1 just as it always has, so drivers are not an issue.
The last sketch I uploaded to my board was a simple LED blinking program. For some reason, when writing to the Arduino (ATMEGA 2560) using the IDE's keywords like PORTB, it never matched up to the processor's datasheet pin layout. For example, if I wrote to PORTB, 4 ports from PORTH and 4 ports from PORTA would light up. It was never consistent and I have no idea why.
Is it really possible for an uploaded sketch to stop the uC from receiving new sketches? The blinking program is still running when the device is turned on, so I don't believe the processor is malfunctioning.
At this point, with the whole "pins not corresponding correctly between AVR Studio and the datasheet pin layout" thing and my inability to upload new sketches, I'm thinking of getting another uC instead of buying an ISP and not even being confident in my IDE's ability to program the controller correctly.
I would love your opinion on my issue. The only thing I haven't mentioned is that I plan on using the Arduino Mega 2560 as a flight controller for an autonomous UAV. I'm not allowed to use the Arduino wiring language, and instead I can only use C (which is why I'm using AVR Studio instead of the Arduino IDE). I'm not sure if I should get an ISP and stick with the ATMEGA2560 or abandon ship and get a controller which will actually do what I program it to do.
Regarding the PORT mismatch: are you sure you've selected the correct target mcu in AVRStudio? The pin numbers on the mega board are not necessarily the same as on the processor.
Also what I can't immediately understand is that the loop-back test has failed although the driver seems to be registering fine. Strange.
The only issue with code blocking the serial interface I've read about is the case when the serial interface is flooded with data. And this only happens on boards that do not use the FTDI bridge chip. A blinking LED doesn't do that and shouldn't matter at all.
If you'll have to deal with hardware like this for a longer period of time, you (or your boss) will never regret getting an ISP (e.g. the cheaper ones from atmel for 35$ or thereabouts) that works with AVRStudio. Most likely it will work with avrdude as well, but you can find that out before you make a purchase. If you need to do hardware debugging it will cost some more.
Getting one will be much better for your mental sanity. It is quite annoying to sit in front of a piece of hardware and you can't make it go...
Dug up this thread I posted just for people who have the same weird, unexplainable problem that I had and have no idea where to turn to.
Well, I fixed this issue. I'm not 100% sure how. But this is what I did.
Bought a usbtinyISP. Soldered that sucker pretty quickly and installed drivers for it. Tried burning a bootloader with the Arduino IDE. Didn't work. Was getting some weird error about mismatch and stuff. Googled it and I saw someone mention that the ISP I bought and used won't work with burning the Atmega 2560. I was pretty upset.
But I noticed that when powering my chip, pin 13 blinked a few times and then proceeded to go into its infinite blinking loop. If anyone forgot my problem it's that I uploaded a weird sketch using another IDE since I'm not allowed to use the Arduino wiring language (the dean of electrical engineering has a bone to pick with you "hobbyists" who don't understand "true" engineering etc etc) and runs it forever and ignores any attempts to upload new sketches Since it blinked a few times it means my bootloader was intact. I uploaded a new sketch with the ISP. It ran a little funky and not quite according to what I wrote. But then I realized it actually went through. I immediately took out the ISP and plugged the USB back into the Arduino and used the Arduino IDE to uploaded a new sketch.
Bingo.
Don't know what happened. Don't care. I'll worry about it again when I break it again.
So: broken uC --> get an ISP --> upload some new code --> go back to using USB to program so I don't maul my bootloader