Getting AVR HEX code loaded onto the ATmega168, QUESTION?

Once again I’m attempting to program an ATmega168, by folowing the tutorial

Beginning Embedded Electronics - 2

Getting AVR HEX code loaded onto the ATmega168

This time I managed to get what appears to be a successful upload, [u]**but my little light doesn't blink.**[/u]

I get: several avrdude messages in my output sheet, ending with

Avrdude: 300 bytes of flash written

:verifying flash memory against blink_1Mhz.hex

: bunch more avrdude stuff

Avrdude: verifying

Avrdude: 300 bytes of flash verified

Avrdude done. Thank you

This all appears to me that the upload was completed OK, but no blinky.

However, I discovered that pin-1 stays at zero; it isn’t being held high.

Would that prevent my atmega168 from operating?

I suspect that it is a bad connection, which I will work on tomorrow, but will the atmega168 operate if pin-1 stays at 0-volts?

Thank you

ptool

Since you didn’t mention it, I am ASSuming you are working with a 28 pin PDIP package, so pin 1 is reset.

Is reset connected to anything? Usually an RC circuit ensures proper reset although it is not mandatory.

a 4.7K resistor from reset to VCC and a 10uF capacitor from reset to GND should take care of it. When the device is running, the voltage at reset should be close to VCC.

edit: I now see the tutorial you are working with and there is no capacitor, just a reset switch.

Did you connect the resistor to VCC? IF you did, it should work. Check that first.

Make sure you programmed the fuses correctly.

newbie123 says:

edit: I now see the tutorial you are working with and there is no capacitor, just a reset switch.

Did you connect the resistor to VCC? IF you did, it should work. Check that first.

Make sure you programmed the fuses correctly

.

The tutorial says nothing about programming fuses, not that I can find, anyway. I was hoping that wouldn’t be a factor, as I know so little about WinAVR, or how to program fuses.

So far I’ve found two problems with my hookup. :oops: I fixed one,which was a bad connection to pin-1 (reset), but still no blinkey. There was still a ground, 0-volts, on that pin. So I looked at the reset switch, and it appears to be sending a permanent ground to pin one. I hate those little four legged switches.

You might wonder why I’m having connection problems. I decided to solder the ckt. together in a PC board; my soldering ain’t the greatest. Apparantly I soldered that little four legged switch in the wrong way. :oops: I hope by removing it, the ckt. will work. I couln’t get anything to work when I was using a solderless bread board.

a 4.7K resistor from reset to VCC and a 10uF capacitor from reset to GND should take care of it. When the device is running, the voltage at reset should be close to VCC.

Thanks newbie

ptoole

So I removed the reset switch, then soldered in a 10ufd cap. from grnd. to pin-1 (reset), and put a 4.7k Resistor from pin-1 to VCC, found another loose connection (female header connects are too large for small component leads, which results in poor connections), hooked the power to the ckt. - LED blinked. But when I connected the programmer to it, the LED stopped blinking. Removed the programmer, LED resumed blinking.

I reconnected the programmer, changed the blink timing in the program, reprogrammed the chip, disconnected the programmer - the LED blinked at the new frequency that I changed the program to. I reprogrammed the blink timing a couple of times, and the LED would blink at whatever rate I set it to. Apparantly the chip will accept the program, but won’t operate while the programmer is connected. Is this the way it is supposed to work?

ptoole

ptoole:
Apparantly the chip will accept the program, but won’t operate while the programmer is connected.[/b][/i] Is this the way it is supposed to work?

ptoole

Probably, YES. The programmer program (whatever you are using - avrdude, or whatever) is probably holding the reset pin low (that’s what it takes to program the avr)

some programs release the reset so you can leave the cable plugged in.

If you want to learn about fuses, look in the datasheet. The most important one you will find that will make your life miserable is the CKSEL fuse. This is the one that gets messed up then you will be locked out of your avr!

Th CKSEL fuse selects the clock source whether it be external or internal clock, and depending on the avr there are other options.

Most likely you have the factory CKSEL fuse setting for internal clock (not sure of the frequency on that avr). That is why your blinky program worked.

If you are just learning, take my advise. Get a breadboard! Its only about $10-$15 for a really good one. You will save yourself a lot of trouble.

If you are ever unsure about a circuit, you can easily throw something together quickly to test if it works without soldering, then desoldering later (especially if you are new at soldering).

breadboard:http://www.sparkfun.com/commerce/produc … cts_id=112

I also saw a kit that has pre-formed jumper wires at different lengths for the above breadboard. This makes it even easier because you don’t have to find a piece of wire and then strip each end, and tin the ends with solder.

Pre-formed Jumper Wire Kit:

http://www.robotshop.us/elenco-jw-140-j … kit-1.html

Best of Luck

Thanks for the valuable information, Newbie.

I have solderless breadboards (Radio Shack), and have used them. In fact I originally used one for this project, but it didn’t work. Never did find out why. I decided to make life harder for myself by building a “permanent” programming board, so I built one by soldering all the parts in except the Atmega168. For the AT-168 I soldered in a 28 pin IC socket (actually two 14’s). It was a re-learning experience. Trying to improve my soldering abilities. Don’t know why; gives an old man something to do.

Thanks again

Patrick

mega AVRs programmed via MOSI/MISO and clock can be operated with the programmer connected if

those I/O pins aren’t used by the application, or

the programmer has resistors in series on those pins

and if

the programmer doesn’t hold the RESET line true.

All programmers I’ve used enable such. These are $45 or so, and use RS232 or USB for the PC interface. Programmers using the PC’s parallel port should be avoided.

Also, you can one-time program in a bootloader and do all future downloads using the PC’s serial port direct to an RS232 level shifter connected to the AVR’s UART pins. One free bootloader (AVR and PC side) is BLIPS, on avrfreaks.net in the projects section

good luck

One of the features of the JTAGICE mkII is that you don’t have to unplug the programmer to have the microcontroller execute the program. When you exit the programming dialog in AVR studio, the programmer releases the reset pin.

Though it’s a nice feature, I wouldn’t expect anyone to pay $300 for that feature alone.

I have this JTAG v1 clone. Works fine with AVR Studio. Doesn’t work with some 3rd party software.

http://www.nkcelectronics.com/avr-jtag- … r-kit.html