Programming without Arduino

Hey guys, I went out and bought an Atmega328p chip that contains the Uno Bootloader. I didn't have enough for an Arduino board or anything, I have it in the Breadboard at the moment with the two caps and crystal. Is there any way to play with it, program it, with a few jellybean parts and the serial/parralel port? I don't know if it would help at all, but I have a Picaxe serial->3.5mm Jack programmer. But yeah, dunno when I can get my hands on a programmer board, so if I could get it programmed by any means now, that would be awesome.

Any ideas?

Thanks,

Aaron :slight_smile:

All you need is some way of connecting a serial (RS-232) signal to the chip.

Most people use a cheap USB->TTL RS-232 dongle (about $2.50 on eBay). The other option is an RS-232 to TTL converter, which consists of a DB9 connector, a MAX232 chip, and some capacitors.

Do not connect the chip directly to an RS-232 port on a computer. Those ports can generate up to +/- 12V which will blow up your chip.

Thanks for the reply.

So there's no way to program it with jellybean parts? I was kind of hoping I could just hook it up via serial directly with a resistor or two, but I guess not. How about the parallel port?

Or will I just have to wait until I purchase a Uno bored?

Thanks! :slight_smile:

You can make an RS-232 to TTL converter with "jellybean" parts, but it's not a simple task.

The RS-232 protocol uses -5 to -12V for a HIGH, and +5V to +12V to +12V for a LOW. TTL uses +5V for a HIGH and 0V for a LOW1. So you'd need to invert the signals somehow, and limit the voltages. Tricky to do properly, which is why the MAX232 chip exists.

I would suggest hitting eBay and getting a USB->TTL dongle. There's millions of them out there and they're dirt cheap. Basic ones just provide the TX and RX signals, so you will have to manually reset the chip at programming time to enter the bootloader (takes practice to get the timing right). More expensive ones based around the FT232 chip can have the DTR signal available, which you can connect to the reset pin of the ATMega328p chip through a 100nF capacitor to auto-reset the chip to make programming easier.


1 Yes, I know, <0.8V for LOW and >1.2V for HIGH is the real TTL values, but 0V and 5V is enough for most people on this site to know. Terry Pratchett calls this "Lies To Children"

Could I just build something like this:

If you have the parts, yes, that might work.

I have seen these circuits sold by (I think it was) sparkfun, and they "just" work, if your serial port is up to the job.

Try it and see.

But still, do yourself a favour and spend your sweety money on a USB->TTL adapter - it'll save you so much hassle in the long run.

haha thanks. I will save up for one, but I'll build this circuit now!

Could you maybe give me a quick summary of programming it? I know how to write my first program, I assume I just connect the Tx and Rx up to the chip, and hit program on the PC?

I'm downloading the IDE now, I've never even used that. Do I just ground the reset pin or something to initiate programming?

I know these answers are probably available, but I'm not sure if it would be the same for the method I'm using, and just wanted to be sure. Any help appreciated.

Thanks majenko :slight_smile:

Connect chip TX to PC RX, and chip RX to PC TX.

Connect RESET to +5V through a 10K? resistor, and to ground through a pushbutton.

Press the button to reset the chip and enter the bootloader at the right time just after pressing the "upload" button in the IDE (as soon as it tells you how big your sketch is).

Oh, and don't forget the 100nF decoupling capacitors on the power pins of the chip.

Looong time back I used similar circuit with one exception (and maybe an issue with your above design): the -12V for transmitting (or better to say something around -6V) was generated from PC's side Tx signal via a diode and a 100uF capacitor.. So the Tx signal from the interface towards PC was +5/-6V. I think you may still google it somewhere..
Yea - still alive: https://web.archive.org/web/20210506195922/http://www.uchobby.com/index.php/2007/06/11/ttl-to-rs232-adaptor-explained/
Edit typos

Awesome thanks guys. Pito, I'll look into that for sure also =)

I've created the cable, had to find some old female pin headers and cram them over the serial pins. Really scavenging here...

But got that all good, now it's time to build the circuit. Right. Now.

Will update you guys soon on progress, hopefully it'll work =)

Thanks!

Ok I have completed the circuit... As expected, I can't seem to get it to upload. I'll continue to check things, but do I have to configure the IDE for serial at all?

I just opened the blinking LED example program, and I get:

avrdude: stk500_getsync(): not in sync: resp=0x30

I'll continue to look for issues with the circuit, but yeah... Hmm..

Any help appreciated, thanks =)

Aaron

For uploading you only actually need the Rx part of the serial circuit.

Have you confirmed that your circuit correctly converts the RS232 active and inactive states to the corresponding TTL states?

Do you know what frequency the 328p is running at? (Do you even know for sure that your circuit is complete? If it's configured to use an external clock and you don't provide one, you're wasting your time.)

Yeah I know but I figured I might as well add the Tx part as well...

I'm running it off a 16Mhz Crystal

You may have a 16 MHz crystal but is it configured to use it? Plus it may have the "divide by 8" clock fuse set.

If and when you get a Uno you can use the sketch here to answer such questions:

Building an Arduino on a Breadboard

Thanks guys,

I've built the exact circuits, for the programming and building it on the breadboard. Every component is exact, and I don't know if a /8 fuse is set or not, not even sure what that is yet (Second day with Arduino today) :stuck_out_tongue:

All I know is I have built both circuits exactly the same (Programming and running the chip on the BB) and that I'm using a Uno chip pre-loaded with the boot loader that came with the 16Mhz Crystal.

For clarification, this is the exact item I purchased: ATmega328P MCU with Arduino Uno bootloader | Freetronics

Attempting to program the chip results in a 5 second wait, and:

avrdude: stk500_getsync(): not in sync: resp=0x00

Thanks for any help in advance,

Aaron

Edit: If I bridge RX and TX from the circuit output to the chip, it returns what I send fine. :s

And you are pressing the reset button during that 5 second wait like I told you?

Uploading without an automatic reset is a mess. Try to acquire a cheap usb/ttl from ebay (DTR or RTS connected to Reset via 100nF cap).
For example: http://www.ebay.com/itm/FTDI-Basic-6-PIN-3-3-5V-For-Arduino-Free-USB-Cable-/230820610037?pt=LH_DefaultDomain_0&hash=item35bdfafff5

pito:
Uploading without an automatic reset is a mess. Try to acquire a cheap usb/ttl from ebay (DTR or RTS connected to Reset via 100nF cap).
For example: http://www.ebay.com/itm/FTDI-Basic-6-PIN-3-3-5V-For-Arduino-Free-USB-Cable-/230820610037?pt=LH_DefaultDomain_0&hash=item35bdfafff5

You may have noticed I gave up mentioning those - it seems to have fallen on deaf ears...

He may have other issues there as well. His PC rs232 may not accept positive only serial, looping via the interface is not a validation it works. I had spent ages with pushing the reset button, but resigned finally. One record of mine was 35 minutes of messing with the reset button in order to push single upload over (via a BT I must admit).. :roll_eyes: