I've did a program using a mega 2560. The IDE compiles and the program runs on the arduino without any problems.
The program will be used in pcb with a stand alone version of the 2560 chip. I assemble one board only with the necessary thing to program the atmega2560 (FTDI, ISP and two led - Attached file).
I'm not using any boot loader and my fuse configuration is the following:
I'm using ATMEL Studio 6.1 +avrisp mkii to set the fuses and upload the hex file compiled with the arduino IDE 1.5.6.
After uploading my test program I notice that one of the sentences displayed with the Serial.print had a spelling mistake "budton" instead of "button"!! If check the program code and everything was correct (baud rate included) .
I changed the IDE to the 1.0.5 version, same procedure as before and everything was ok.
I assemble the rest of the board and uploaded the hex of the complete program and again several typos in the sentences, some times restarts or random number appear on the variables.
I still can upload the hex using the atmel studio but the program or don't run or has a strange behavior or simple restarts by no reason!!!
Did I manage to damage the microcontroller or do I have a problem in the way that I'm uploading the code (Arduino IDE +ATMEL Studio 6.1 +avrisp mkii)??
Sorry for the long text but this is not for me a programming error but something that is going wrong in the compiler/burn phase.
Please feel free to ask for more information necessary for this problem.
mega2560.bootloader.low_fuses=0xFF
mega2560.bootloader.high_fuses=0xD8
mega2560.bootloader.extended_fuses=0xFD
You used FE.
That only changes the brownout level some
FE 110 min 1.7 typ 1.8 max 2.0
FD 101 min 2.5 typ 2.7 max 2.9
I don't see that anything you've described, or your design, would be an issue.
What's the last code thing you did?
Got the serial port busy blasting messages got?
Is there a !!! in the code somewhere? That was an issue earlier on that should be resolved by now.
Yes, I send a lot of messages through serial. Can this be causing problems? I will try some small delays and check to see what happens.
My test code is very simple, basically read/write ports and Serial print variables.
My program code is compiled without errors and I already test it in the Mega so I don't think that this can be causing the problem . Also many serial prints are used.
So by my description, the chip should be fine? My problem is only software?
Should I use atmel studio to compile and program?
I think your problem is only software.
When I have had issues in the past accidentally blasting out tons of serial, I had to press & hold reset during the download, releasing it when the IDE showed "compilied xxx of 128xxx bytes".
Or reburning the bootloader, that definitely clears any problem program out.
Without seeing code I can only guess but make sure you aren't depleting the chips RAM
which would cause weirdness. Also make sure it is getting clean power
I've check every suggestion and I believe that the problem is in the amount of data that I'm sending on the Serial.prints
I can program again using the hex file and the program run a little better.
I've added the test code in the attached file.
I increase the size of the serial buffer in the HardwareSerial.h. and things got better however I still have typos in the main program.
Another thing, I'm using progmen to print out many of my messages in the main program, using the "Array of Strings" example of this page http://arduino.cc/en/Reference/PROGMEM
I will try to increase the size of the buffer and see what happens.
My power source is clean. On my test prototype the power is coming from the FTDI cable.
So what can I do now? Use serial.flush and wait for every serial print to be completed. Any other method?
Or can I still have a problem in another part that is causing the typos?
Thanks for the replays they really help me in looking another way in problem.
HG