NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » I replaced the Micro with a ATMEGA168P-20PU--->ISSUES?!?!

January 27, 2010
by Redlight
Redlight's Avatar

Hello,

I've bought a ATMEGA168P-20PU to replace the ATMEGA168-20PU because it stopped working for a some reason (probably incorrect wiring). Now everytime, i run 'make', it produces this error:

avrdude -c avr109 -p m168 -b 115200 -P COM4 -U flash:w:initialload.hex:a

Connecting to programmer: . Found programmer: Id = "" ""; type = Software Version = . ; Hardware Version = . avrdude: error: buffered memory access not supported. Maybe it isn't a butterfly/AVR109 but a AVR910 device? make: *** [initialload-upload] Error 1

Is there anyone who can assist me with the 'makefile'? I thought i'd try it out but i know its got to be the avrdude switches.... I dont understand the makefile as per i'm going through c programming skill set atm....

January 27, 2010
by Rick_S
Rick_S's Avatar

Where did you purchase your replacement micro-controller? If you purchased it here, you shouldn't need to do anything special. Otherwise, if you want it to behave as a Nerdkit micro-controller, you will need to do some additional steps requiring a different type of programmer to get the NerdKit bootloader installed.

The error you got can be caused by several things and in it's simplest sense, means that avrdude can't talk to the micro-controller. This can be wiring issues, or a wrong or missing bootloader on the chip.

If you did buy the chip from the NK guys, post a pic of your setup and maybe we will be able to spot the problem.

No matter what the problem, there's a good chance we can talk you thru it.

Rick

January 27, 2010
by treymd
treymd's Avatar

Yeah I got something similar a few hours ago, my problem (not saying it's your's because you probably need a bootloader) is that my uart ground wasn't grounded :)

January 28, 2010
by Redlight
Redlight's Avatar

I'm very confident on the wiring but i believe i can not just buy a micro off the self. There must be something that is done, and its that step that i'm not sure to begin.

From Rick_S explanation, i could be missing a bootloader?!?!

Again, i can point that the ATMEGA168P will not work as a substitute for a ATMEGA168, straight out of the box, per say. I am researching as i go, but if any one can point me to the right direction, that would be faster..

January 28, 2010
by Rick_S
Rick_S's Avatar

Ok, Based on what you have stated, I'll assume you didn't purchase your replacement from the NK guys.

If you want the micro-controller to behave exactly as the original you received in your kit you will have to flash the bootloader onto the chip.

By default a new micro-controller of this type:

  1. Does not have any code in it's flash memory.
  2. Does not accept programming via the serial RX/TX (pins 2 & 3).
  3. Is clocked by its own internal 8Mz oscillator divided by 8 for a 1Mhz clock.
  4. Requires a different type of programmer than provided in the Nerdkit.

Now, back to my original question. Where did you purchase your new micro-controller. The reason I ask this is that some places - especially some ebay vendors - will sell a chip pre-programmed with an arduino bootloader installed where electronics distributors such as Mouser and Digikey sell virgin blank chips.

If you purchased a blank chip and want it to behave like a NerdKit Chip you will need to do the following:

  1. You will need to purchase or make what is called an ISP programmer. This is the factory default method of programming the chips. There are several types out there from the USBASP you can purchase to pc parallel cable mods that make the built in parallel port on your PC (not a USB to parallel adapter) a generic ISP programmer.
  2. In your code folder, there is a folder called bootloader. That folder contains a pre-compiled hex and a makefile that will set the fuses in your new micro-controller and install the bootloader for you. The make file is set for a Generic parallel cable programmer (-c dapa). If you do not use the generic parallel cable, you will have to change the (dapa) to reflect what you are using.
  3. Once you have you programmer, and you have modified the programmer type (if need be), all you have to do is connect all the power / ground connections to the micro-controller to the power/ground rails on the breadboard. Then make the connections between the ISP programmer and the appropriate pins on the chip and power/ground rails (if needed for your programmer type). Then change to the boodloader folder and run make.

If your chip has a bootloader such as arduino already installed, you will need to do a chip erase prior to running make.

Hope that helps,

Rick

January 28, 2010
by Redlight
Redlight's Avatar

Hi Rick_S

Thanks for replying and helping me. Are all ISP the same? For example, are the USBasp and the atmel Mature ISP Programmer identical?

Now, if i were to by acquire one. All i would do is wire up MOSI (PB3), MISO (PB4),SCK (PB5), RESET (PC6) on the micro to the ISP? Assuming that i have configured the bootloader makefile appropriately?

January 28, 2010
by Rick_S
Rick_S's Avatar

I'm not familiar with the Atmel Mature ISP programmer. You would most likely want to get an ISP programmer that is supported by AVRDuDe. You can go to their support page to find that - it is a fairly large list. Then get what works best for you.

To answer your second question, Yes you would connect those, a ground connection and depending on the programmer possibly power connection.

On the microcontroller, you would only connect the 2 power and 2 ground connections as well as install the crystal and bypass cap. (because once the fuses are set, you will need the crystal for the chip to work)

At that point, adjust the makefile for your programmer and you should be good to run make.

January 29, 2010
by Redlight
Redlight's Avatar

Rick_S,

Thanks again for pointing me to the right direction. I have a STK500, and i did it thru AVR STUDIO. I matched the fuse bits, lock bits and used the Bootloader.hex as per another thread.

You gave me an idea, and i was able to search the forum for solutions. I certainly appreciate the support. IMO, its very hard to get started in microcontrollers, theres simply too much permutations and combinations.

I guess thats why the NK are popular because it skips alot of that and gets the user to build circuits straight away. The tutorials and sample code are just Gold.

January 29, 2010
by Rick_S
Rick_S's Avatar

No Problem. Glad to hear you got it done. One of these days I may have to buy an STK500. It'd be nice to have not only the ISP but high voltage parallel programming available if I were to mess something up. :D

Rick

Post a Reply

Please log in to post a reply.

Did you know that you can build a digital read out (DRO) for a lathe or milling machine? Learn more...