Go Down

Topic: Problem with serial output ... (Read 138 times) previous topic - next topic


Dec 16, 2018, 01:24 pm Last Edit: Dec 16, 2018, 01:35 pm by Softfoot
I need to be able to program my Mega2560 via a USBasp because I need to disconnect the CH340 USB device tio save power in a battery application.

My code works correctly if programmed via the USB port and I then see serial output at 115200 baud.

Replacing the USB connection with a TTY<->USB adapter also works correctly on TX0/RX0.

However, if I program the device via the ISP port with an USBasp the code appears to be running (bus and pin activity seems OK) but I get no serial output on TX0/RX0 !!

In programming it this way I have of course trashed the bootloader - is some init of the serial port done in the bootloader that I need to add to my setup code ???

At present I just have "Serial.begin(115200);"

Reburning the bootloader, I can then program via the USB port as normal.

What am I missing ?



Dec 16, 2018, 01:43 pm Last Edit: Dec 16, 2018, 01:45 pm by sterretje
The Serial.begin() should be sufficient if you don't have a bootloader. You haven't, by accident, (re)connected the TTL-to-USB incorrectly (e.g. RX and TX swapped)?

Other option might be that you might have set the fuses incorrectly and the baudrate is now incorrect.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.


Dec 20, 2018, 12:57 pm Last Edit: Dec 20, 2018, 01:41 pm by Softfoot
Hmmm ... It doesnt even output over USB - so its not a pin swap issue.

It would appear that my comment about the code running was rubbish ... it isnt.

If I put "blinky" on the board via USB+bootloader it is OK.
But if I program it via my USBasp it doesnt run :-(

I have used the USBASP to load standalone code before so I know the USPASP is OK - and it programs without error.

The USBASP is clearly working as it is able to restore the bootloader.

What am I missing ??

Is there some secret tweak (init code/fuse setting/library) needed to load a standard sketch via a programmer ?

I am in the process of setting up my Atmel-ICE to try that as a programmer - I'll add the results later, but I suspect the outcome will be the same.



OK after a bit more testing :-

On an UNO I can upload "blinky" via BOTH the USB port an the USBasp and it runns correctly.

But on 2 different Mega2560s I can only upload "blinky" via the USB port --- via the USBasp it appears to complete OK but it will NOT run.

In all cases the USBasp is able to restore the boot loader.

I did try the ATMEL-ICE but it needs the "auto-reset" being disabled - and I am loathe to do that at this stage.

PLEASE - someone must have hit this before ...


... they did - just a question of finding the blighter!!


It seems that the Mega2560 needs the BOOTRST fuse set to 1 (it would appear that the UNO doesnt).

I hope this helps someone else.

To me this should be documented in the arduino suite somewhere.

Dave (Phew!!)

Go Up