If you want to use the AVR serial port for your application can you still use the bootloader?
However, the bootloader is connected to the USB-serial interface and your application's serial interface. Usually, these two UART sources are simply connected together electronically and the application's serial idle state (at +5V or +3.3V) is not "stiff" enough to prevent the USB-serial from pulling the RX line down to logic low (about 0.3 Volts max).
But, if the application's serial sends data to the AVR during the interval where the AVR is burning new flash application code, then this will corrupt the loading process for the bootloader.
In other words, your application needs to signal to the external serial source when it's OK to begin sending data, if possible.
If you do not have the ability to shut off the data from the external serial source, then you need to prevent this data from mixing with the data that is being used by the bootloader. An example of this is a MIDI-IN that is connected to a synthesizer keyboard. The keyboard puts out a signal (one byte: 0xfe:31250 baud) every 300 milliseconds to let the rest of the MIDI system know that it is functional. This "Active Sense" signal will always screw up a new firmware update to the bootloader. And there is no way to shut it off on any MIDI keyboard that I've examined.
In this case I put a 74HC125 TTL chip hex buffer in the circuit between the external serial and the AVR Rx serial. There is one pin used to engage or disengage the HC125 buffer. When disengaged, the external serial signal is invisible to the AVR RX input. The software switches the buffer off or on. This IC buffer control pin is active low. I add a 10K pull-up resistor to this line so when the AVR is reset, the resistor pulls the line high and the buffer goes inactive, and the external serial is not seen on the RX line during the bootload process.
Or, use a two-pin jumper on the external serial. Have the jumper off when doing code development and on when running the application.
Is there any documentation on how the Arduino bootloader works?
I would like to use the serial port on an Ardiuno UNO and still have the bootloader.
You can do just that. Just put calls to Serial.begin(), Serial.writeln() etc in your sketch and they still work. The bootloader and your app code don't interfere with one another as they don't both run at the same time. Either you are bootloading (it's called "Optiboot" by they way - tons on the internet about it) and that uses the UART/USB or you are running your own code and it optionally makes use of UART/USB. From the PC side the USB looks like a CDC-ACM device so the "PC view" never changes. Again, at the PC end different software may use that CDC-ACm created COM port. Either the arvdude software when it is sending new programs to the bootloader. Or probably some kind of terminal software when it is communicating with your use of Serial.methods() in the Arduino code.
(all this is equally true if you aren't writing "Arduino software" but just programming UCSR0A, UCSR0B, UDR etc direct - your app use of it to communicate to PC terminal all happens at a different time to when avrdude and Optibot might be using it to communicate).
What are you connecting to the serial port? Can it be disconnected when you want to load new code?
Oh I misunderstood - I thought he meant to use the app for the end to end UART to USB to PC link it provides. Didn't realise he might mean UART to local device. As UART is (normally) 1 to 1 I guess you might require some kind of multiplexing?
Cliff, you'd normally remove the shield when you want to reprogram methinks.
If you're using an Arduino Uno, you can connect your serial device to any two pins, and use the software serial for comms to the external device.
There are also other Arduino's with more then one h/w serial port.
Click Link: Get Free Stock: Retire early!
© 2018 Microchip Technology Inc.