I'm working on a project that uses the hardware serial interface of the arduino uno.
The problem that I'm having is that everything works when I power the arduino via the usb port, but when I only use an external power supply the serial communication stops working.
I googled about this issue and found out that it has to do with the bootloader that on startup looks for data on the serial port, but on startup the device I'm trying to talk to is already sending date so the bootloader gets confused and fails to load the sketch stored in its memory.
A solution that I found is to overwrite the bootloader by using the .hex file of my sketch and an external AVR programmer. I tried this first with the simple blinking sketch and everything worked fine even with the external power.
When I upload the .hex file of my sketch using the serial communication, it does not work. It even seams like the RX and TX pins are connected, Wich seems verry unlikely.
Has anyone encountered this problem and is there a solution?
I googled about this issue and found out that it has to do with the bootloader that on startup looks for data on the serial port, but on startup the device I'm trying to talk to is already sending date so the bootloader gets confused and fails to load the sketch stored in its memory.
Wrong, on startup the bootloader wait looking for a magic sequence of chars, if it gets that sequence it loads a new program if not then your existing sketch is simply run. It is not loaded from the bootloaders memory.
Not running with only external power normally means a flat battery or not enough external power.
With out the bootloader you cannot load a sketch over serial that's what the bootloader does.
freespirit2907:
but on startup the device I'm trying to talk to is already sending date
Haven't you both described the problem and the solution?
The device sending the data should wait until the Arduino is ready (and that is true for communication over the USB connection as well as direct connection to the Rx and Tx pins).
Look at how that is done in this Python demo by waiting for the Arduino to send a "ready" message.
If you absolutely cannot prevent the device from sending data when the Arduino is not ready you can disable the autoreset feature (Google will find the answer for you).
holmes4:
Wrong, on startup the bootloader wait looking for a magic sequence of chars, if it gets that sequence it loads a new program if not then your existing sketch is simply run. It is not loaded from the bootloaders memory.
Okey seams like my information wasn't correct. So the bootloader still on the chip shouldn't be a problem then?
holmes4:
Not running with only external power normally means a flat battery or not enough external power.
My external power is a 12V supply capable of sourcing 3Amps. Should be enough
holmes4:
With out the bootloader you cannot load a sketch over serial that's what the bootloader does.
I know, I used a AVR dragon and atmel studio, just to try if the bootloader was the issue.
@KenF Does that also aplie when I'm only using the uart interface? the other device isn't connected through the usb port.
@Robin2 the device is already sending data and I don't control the device I'm just trying to interact with what it is sending.
I know it's powering up, I tried an easy program that isn't using serial (like blink) and it worked fine.
I could use Software serial of I didn't need serial interrupts and parity. But unfortunatly I do :\
Maybe it helps when I give some more info on my project:
My laptop communicates over serial using an usb to uart(ttl) converter, with a device, the tx of my pc is connected to directly to the device but the tx of the device gose to the rx of the arduino, I change some bits in the data and use the arduino's tx to send to the rx of my pc.
I hope that helps a little xo
Many thanks for the ideas you already sujested guys
freespirit2907:
I could use Software serial of I didn't need serial interrupts and parity. But unfortunatly I do :\
You could probably add parity checking to the simple code in this demo yet another software serial It already uses an interrupt to detect incoming bits.