Is it possible to program a standalone Atmega328p using a computer that has an RS232 port connected through a simple RS232(+12, -12V) to RS232(0, 5V) converter to the RX and TX pins of the Atmega?
If yes, what program (monitor) has to be first installed on the Atmega328p to make this micro-controller able to communicate directly with the computer?
Can Arduino Uno R3 be loaded with a sketch that transform it into an RS232 to USB converter for the case when the computer has no RS232 port?
I need to program and debug a stand alone Atmega328p micro-controller which has only two free pins RX and TX, the rest being assigned to do various things. I know how to write hex files in stand alone AVRs using Arduino Uno but I need four pins for this: RESET, MISO, MOSI and SCK and I can use them only one time to load the monitor, for instance. After the micro-controller is connected to various circuits I can no longer utilize these four pins and only TX and RX remain available.
Using ICSP, if your other circuits do not have outputs driving MISO, MOSI, SCK, then you can program all you want using File:Upload Using Programmer (with a programmer connected).
If they do have outputs and the outputs are disabled when the Programmer asserts & holds Reset, you're still good. If the pins only connect to circuit inputs, you're all set.
Any TTL-level RS232 serial interface can communicate with the Arduino over serial, so the converter off a full voltage RS232 port is fine. Just use the arduino serial monitor with the appropriate port selected. Nothing fancy.
To program the other arduino, though, you need a serial converter that provides you with a DTR line too (also shifted to TTL levels), or you need to have very good reflexes pushing that reset button at exactly the right time while uploading.
You know, USB to TTL serial converters are really cheap, right? Like, under $5 shipped... You should really just buy some. Get a couple, imo - I think they sprout legs at night and try to run away.
The uno contains a USB to TTL Serial converter (it's done with the '16u2).
If your Uno is the socketed kind, you can carefully remove the chip, and jumper ground, tx, rx, and reset to the other board to just use it's converter. This is a last-resort method - not the recommended way. But it works.
What boot-loader (monitor) do I have to load first in my standalone Atmega328p uC because it is empty now?
My hex files are not generated using Arduino IDE. How can I use the commands "Serial.available(), Serial.read, Serial.write or Serial.print"?
I will buy an USB to TTL adapter but this will take some time.
Is it possible to transform somehow the Arduino Uno R3 that I have into an USB to TTL adapter without removing any hardware, just by loading a sketch into the Atmega328p that exists on the Arduino Uno R3 development board?
Computer----USB-----Arduino Uno R3 as USB to TTL==========(Rx, Tx)Atmega328p
Monitor? I have no idea how that word could relate to bootloaders. If you want to upload code to it like it was an Arduino, over serial, you need to burn the appropriate version of optiboot (8mhz or 16mhz, depending on clock speed). You can do this from the IDE with an ISP programmer (or arduino uno running Arduino as ISP. If you want to upload using ISP, you do not have to load any bootloader, you just need to set the fuses.
ISP = programming using miso/mosi/etc, and an ISP programmer, which can be another Arduino running the Arduino as ISP sketch. This is the only (well, there are other obscure ways) way to set fuses or burn bootloader. It can be used to program hex files. No bootloader is needed, and any bootloader present is erased when another hex file is flashed.
The bootloader is needed for uploading over serial - you must burn the bootloader using ISP programmer, and after that, it can be programmed over serial like an Arduino (assuming you wire it the same way)
include the required files from the Arduino core, or write your own. If you want to write arduino (easy mode) code, why not just use the arduino IDE?
There are ways to make the '328p ignore the serial - but if you want to program the second arduino over serial, you're going to need to reset the second arduino based on the DTR signal, or have insane reflexes on the reset button - but if you tie the reset lines together, the bootloader on the first arduino will also run, and try to respond, and everything will go to hell. Of course if you had another ISP programmer, you could remove the bootloader from the uno, making the chip inert, and then tie TX, RX, RST, Gnd and Vcc to the second '328... and then put it back when you're done. That sounds like a pain though.
Can use the USB/Serial on the Uno - just connect Reset pin to Gnd.
Then can connect the Rx and Tx to your other chip. Have to reset the other chip manually.
CrossRoads:
Can use the USB/Serial on the Uno - just connect Reset pin to Gnd.
Then can connect the Rx and Tx to your other chip. Have to reset the other chip manually.
That sounds encouraging.
When do I have to reset the Atmega328p (preloaded with a boot-loader) on the breadboard?
Somebody in a post talked about insane reflexes, that I need, to be able to press the reset at exactly the right time?!
I expect the boot-loader to wait a number of seconds, after a reset, looking for a new hex file and only after that, if nothing is received, to allow whatever code was already present in the micro-controller to run.
That is the reset of the target board, not that of the Uno that is "abused" as an interface (that one needs to be kept in reset during the entire procedure).
Paul__B:
Essentially, you hold the reset as it is compiling, and release it as you see the "Uploading" message in the blue bar.
My hex files are already generated. I just have to upload them in the Atmega328p on the breadboard. Does the boot-loader know to talk directly to "avrdude"?
When I programmed empty Atmega328p uCs on the breadboard, using an Arduino Uno R3 as an ISP programmer, the only thing I had to do was to press Enter after writing avrdude commands like this:
Will such a command work if Arduino Uno R3 is used this time as an USB to TTL converter and the Atmega328p on the breadboard is preloaded with a boot-loader and connected to Arduino Uno like this: Arduino Uno(RESET=GND, TX, RX) -> Target Atmega328p(manual RESET, TX, RX)?