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 » AVR Programming without bootloader

October 26, 2012
by TuffLux
TuffLux's Avatar

I'm looking for a programmer for AVR chips which will allow me to program without the need for a bootloader.

Minimum requirements:- Simplicity - ZIF socket or similar, USB connectivity and possibly powered by USB as well, Compatible with as many different AVR chips as possible, Compatible with AVR Dude or AVR Studio,(Probably other requirements that elude me at this moment)

What programmer would you suggest?

October 26, 2012
by JimFrederickson
JimFrederickson's Avatar

I wouldn't get a "programmer that is prebuilt with a ZIF Socket".

I would just use one of the many AVR ISP Programmers and then build a small board with a ZIF Socket that you attach the AVR ISP Programmer to to program your chip.

(ISP, stands for "In System Programmer". Atmel has created a hardware/software solution that I believe ALL AVR Microcontrollers support quite literally by definition.)

I use the Atmel ATAVRISP2.

You can get it from numerous sources. (Mouser.com, Digitkey.com, etc...)

There are other ISP Programmers that work as well. (In fact there are posts here on how to make your own!)

For Atmel Programmer details look here:
AVRISP

For the AVR ISP to work you need a Microcontroller that is in a hardware environment it will run in. (Hence the need for a little board to be made!)

For that I use: ATmegaXX8

I built the first little board for this mostly identical to the Nerdkits Circuit.

ATmegaXX8

On the top right is the standard header for the AVR ISP.

NOTE: as well that the crystal I use is in a Female Header so that I can change that when I want.

October 26, 2012
by Noter
Noter's Avatar

Here's a couple of resources for you -

Nerdkit bootloader installation is about putting the bootloader on new chips but has some good info on ISP programmers. Rick is a great resource on ISP programmers.

Nerdkit ISP Programmer will show you how to make an ISP programmer from your Nerdkit.

I've never bought a programmer but have made several variations of the ISP programmer using my Nerdkit and most recently a version on the Arduino Nano.

October 26, 2012
by TuffLux
TuffLux's Avatar

Thanks for all the replies.

I was hoping for an 'all-in-one' solution similar to the STK500 so I didn't have to have multiple boards for multiple chips.

As I can see, most of the chips I'll be using will be 'Tinys', but occassionally there'll be the need for a 'Mega'.

Does anyone have any experience / reviews on the STK500 or similar?

October 27, 2012
by Noter
Noter's Avatar

Any isp programmer can program all the ATmegas.

October 27, 2012
by Noter
Noter's Avatar

As well as the ATtiny's.

October 27, 2012
by Rick_S
Rick_S's Avatar

"As well as the ATtiny's."

Except for a very few such as the ATtiny10. That series uses a different protocol. I don't see a lot of those in use though.

Which tinys were you wanting to program, TuffLux?

October 27, 2012
by JimFrederickson
JimFrederickson's Avatar

I had purchased the Atmel STK500 and another AVR Programming Solution similar to what envision. (Ever so long ago now.)

Both were Serially Connected solutions.

I was VERY disappointed in both.
(If I remember correctly for the STK500 there were onboard jumpers that were not clearly marked, at least to me, that had to be changed for different chips that was the root of my disappointment...)

There still are some Professional Programmers that do what you are asking, but most decent ones are quite expensive.

How many different AVR Chips do you think you will need to use?

I have 1 board I use to program, and a backup board, and every project I have has the ISP Connector on at least the first project board. (Adding an ISP Connector is simply adding 1 6-pin dual-inline header to the working project board.)

For my main board I use to program the AVR's I also have some adapter boards I made so that I can just plug-in bigger and smaller AVR's into the same board to program.

Peoples needs, and things that make them happy are different. I don't really espouse for a one-size-fits-all theory in anything.

For me though using the Atmel ISP Programming Interface with a designated target board or my current project board is what I prefer, no matter what ISP Programmer I am using.

October 27, 2012
by Ralphxyz
Ralphxyz's Avatar

If you are looking at other programmers I would be very cautious of getting a STK600 (Atmel's latest replacement to the STK500).

You can "potentially" program everything from Atmel but they tend to only last 3 months.

I have close to a thousand dollars invested in my STK600 and it is dead.

I really like my Atmel Dragon it also does high voltage parrallel programing which I use often.

Ralph

October 27, 2012
by TuffLux
TuffLux's Avatar

Currently I'm looking at programming the Tiny4's. They have just enough pins for what I want and are very power efficient. The only problem I have is that I'll have to program them using HVSP. So that eliminates ISP programmers.

I do see the Tiny5 has an ADC which could become useful, if only I could find a supplier of those...

October 27, 2012
by Noter
Noter's Avatar

That is interesting, those little mcu's were not even on my radar. Just for fun I'll have to get a few of the Tiny10's so I can modify the isp programmer to program them too.

October 27, 2012
by TuffLux
TuffLux's Avatar

Noter :-

Would be interesting to see.

I'm pretty sure you can't use an ISP programmer to switch all four pins to I/O though. I think you need to use a HV programmer.

October 27, 2012
by Noter
Noter's Avatar

I would just use the isp programmer as a base because it has all the logic to play with avrdude already in it. The task is to change the interface wiring and command set to be compatible with the Tiny4-5-8-10's and then call it a HVSP programmer. I made a HV programmer for the ATmega44-88-168-328's that I developed in the same fashion so I'm pretty confident it will work. I've already added tiny10's to my pending mouser order and will probably place it next week.

October 28, 2012
by Rick_S
Rick_S's Avatar

This Blog was where I got my 1st exposure to those little critters. I haven't really played with them though, just knew they were around. They might be great for simple 1 or two channel PWM or ADC work of some sort.

Rick

November 15, 2012
by Noter
Noter's Avatar

Got my ATtiny10's this week and they are really tiny! It was difficult to get it soldered onto the adapter because it was almost impossible to hold down and solder at the same time. Just looking at it made it move!

ATtiny10

So now it's on to the fun part, making a TPI programmer and then getting the tiny10 to blink a few leds. I'm using the same nerdkit setup as the AVR_ISP programmer but not messing with the bootloader this time around, just loading direct with my ISP programmer. Then I can test the TPI programmer using the nerdkit usb cable connected directly to the ATmega328 on the breadboard.

AVR_TPI

November 16, 2012
by Rick_S
Rick_S's Avatar

Those little buggers are cute, but I don't know if I'd ever have a use for them. I can see what you mean about breathing on them making them move! What are your intended uses for them??

November 16, 2012
by Noter
Noter's Avatar

I don't have a specific use for them yet beyond just learning. I can see where they might be useful for pwm control of brightness and contrast on a LCD or something like that. But they have no built-in eeprom so keeping a setting can't be done without external help. Next time I order from Mouser I think I'll get a couple of these tiny 128 byte eeproms to try out -

eeprom

November 16, 2012
by Ralphxyz
Ralphxyz's Avatar

Just looking at it made it move!

I use a drop of Super Glue to hold them while soldering.

The heat of soldering will sometimes break the bond but it usually holds long enough to get everything soldered.

Ralph

November 16, 2012
by Noter
Noter's Avatar

Thanks Ralph. I'll give that a try next time.

Paul

November 19, 2012
by Noter
Noter's Avatar

Here's a little program that will fit on the ATtiny10. Doesn't do much, just randomly blinks a LED to sort of simulate a candle. Main thing now is just to get something that fits because the ATtiny10 only has 1k byte of flash.

// LED-Candle.c
// Single LED Candle Simulation

/*
Use the following compile/link command to produce the 686 byte hex file.
Modify as necessary for your MCU and F_CPU.

avr-gcc -g -Os -mmcu=atmega328p \
        -L/usr/local/avr/avr/lib \
        -Wl,--relax \
        LED-Candle.c -o LED-Candle.o \
        -DF_CPU=18432000UL -DMCU=atmega328p
*/

#include <stdlib.h>
#include <avr/interrupt.h>
#include <util/delay.h>

ISR(TIMER0_COMPA_vect, ISR_BLOCK) {
    PORTC &= ~(1<<PC2); // turn off
}

ISR(TIMER0_OVF_vect, ISR_BLOCK) {
    PORTC |= (1<<PC2); // turn on
}

/**********************************************************************/
int main() {

    // set pin for output
    DDRC |= (1<<PC2);

    // start the timer
    TIMSK0 |= _BV(OCIE0A) | _BV(TOV0);
    TCCR0B = _BV(CS00);

    // enable interrupts
    sei();

    while(1){
        OCR0A = (rand()&127)+128;
        _delay_ms(100);
    }
}
November 19, 2012
by Noter
Noter's Avatar

Got it down to 640 bytes by switching to timer2 and PB3 so that fast PWM does all the work.

// LED-Candle.c
// Single LED Candle Simulation

/*
Use the following compile/link command to produce the 640 byte hex file.
Modify as necessary for your MCU and F_CPU.

avr-gcc -g -Os -mmcu=atmega328p \
        -L/usr/local/avr/avr/lib \
        -Wl,--relax \
        LED-Candle.c -o LED-Candle.o \
        -DF_CPU=18432000UL -DMCU=atmega328p
*/

#include <stdlib.h>
#include <avr/interrupt.h>
#include <util/delay.h>

/**********************************************************************/
int main() {

    // set pin for output
    DDRB |= (1<<PB3);

    // start the timer
    TCCR2A = _BV(COM2A1) | _BV(WGM21) | _BV(WGM20);
    TCCR2B = _BV(CS20);

    while(1){
        OCR2A = (rand()&127)+128;
        _delay_ms(100);
    }
}
November 20, 2012
by Rick_S
Rick_S's Avatar

With only 1K of flash, I would have thought assembly would have been the way to go. Good job getting the C to compile down that small. Is it the rand function eating up the bulk of the space? Do I remember correctly that the underscore before a function call forces a jump to a single occurrence of the code in the binary? Anyway, pretty cool to see you have the little micro running. Of course, I never doubted you would.

Rick

November 20, 2012
by Noter
Noter's Avatar

Hi Rick,

I don't actually have it on the ATtiny10 yet. Wanted to get it working on the Nerdkit first so I know the code is good when I do get it loaded onto the ATtiny. Sorry to mislead.

Yep, the rand() is the bulk of the code. Without it the size is 166 bytes so the rand() is 474 of the 640 bytes used.

Assembly is probably the best way to go but I am very rusty on assemblers and also have not written a program for the AVR in assembly yet so the easy out for me is to write it in C. The tiny chip has only 32 bytes of SRAM and probably that is the real limiting factor for doing anything very complicated anyway.

I am not familiar with using an underscore before a function call and I couldn't find anything on it in the documentation. Must have been another language/platform.

Paul

December 03, 2012
by Noter
Noter's Avatar

Got the new TPI programmer working and now have my candle emulator running on the ATtiny10. Couldn't use the lib version of rand() but fortunately found suitable code on the web that only uses about 1/2 the flash anyway. This version of the test program occupies only 238 bytes of flash.

// LED-Candle.c
// Dual LED Candle Simulator

// output PWM on OC?A
// timer0 on ATtiny - OC0A, OC0B - PB0, PB1

#include <avr/interrupt.h>
#include <util/delay.h>

/**********************************************************************/
int main() {
    // bump clock to 8MHz
    CCP = 0xD8;
    CLKPSR = 0;

    DDRB |= _BV(PB0);   // set OC0A output
    DDRB |= _BV(PB1);   // set OC0B output

    // start the timer
    OCR0A = 3;
    OCR0B = 3;
    TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00);
    TCCR0B = _BV(CS00) | _BV(WGM02);

    // ref http://rosettacode.org/wiki/Linear_congruential_generator
    #define RAND_MAX_32 ((1UL << 31) - 1)
    uint32_t    rseed = 0;
    while(1){
        rseed = ((rseed * 214013UL + 2531011UL) & RAND_MAX_32) >> 16;
        OCR0B = OCR0A;
    OCR0A = (rseed%128)|128|3;
        _delay_ms(100);
    }
}
December 05, 2012
by Rick_S
Rick_S's Avatar

Perfect time of year to build a fake candle. Justify the hobby to the wife as "I'm designing Christmas decorations... " BigGrin_Green

Good going on the programmer modifications. I'm going to have to mess with that one day. I've often thought the ATMEGA32U4 (Like the TEENSY) based boards would make a good programmer since they have built in USB support, but have never tried it. Ahh... a project for another day.

Thanks for the update,

Rick

December 08, 2012
by Noter
Noter's Avatar

My wife likes the fake candle. It makes a great night light too. I taped a piece of decorative paper together to make a cylinder and just set it over the leds. Looks almost real. It looks brighter in the photo than it really is.

http://i.imgur.com/OojMxl.jpg

I had the same thought on using the built-in USB and bought a couple of 32U4s a several weeks ago with a Mouser order. Then I laid out a TQFP-44 adapter and ordered a few from OshPark and now have one put together ready to go. Updated lcd code to use different pins and it is working in a little test program so now I can get busy on the USB. I think I'll start with the LUFA libraries and see how that goes.

http://i.imgur.com/nCpF1l.jpg

January 04, 2013
by Noter
Noter's Avatar

I got my tpi programmer working on the ATmega32U4 using the LUFA library. But it's a big chip with 44 pins so I switched over to the AT90USB162 and it's definitely a better fit for the TPI programmer. I found a SOT-23 socket on eBay that will work well for the ATtiny10 so now all I have to do is design a PCB to get it off the breadboard and make it a permanent fixture in my bag of tricks. Maybe in a month it will be completely done.

USB_TPI

January 05, 2013
by Rick_S
Rick_S's Avatar

Looks real good, what's the little 8 pin IC in between the AT90USB162 and the ATTINY10?

January 05, 2013
by Noter
Noter's Avatar

It's a max662 and puts out 12v to enable HV programming on the tiny10. It's all powered from the USB 5v so needed something to get 12v. The thick red and black wires go to my multi-meter.

Post a Reply

Please log in to post a reply.

Did you know that hobby servos are controlled through a particular kind of PWM (Pulse Width Modulation) signal? Learn more...