# new avr user with tiny2313 and mega168 and olimex boards

**URL:** <https://community.sparkfun.com/t/new-avr-user-with-tiny2313-and-mega168-and-olimex-boards/3294>\
**Category:** MicroMod\
**Tags:** avr-atmel\
**Created:** [December 11, 2006, 9:18pm UTC](https://community.sparkfun.com/t/new-avr-user-with-tiny2313-and-mega168-and-olimex-boards/3294 "2006-12-11T21:18:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwrenne](https://avatars.discourse-cdn.com/v4/letter/d/cab0a1/32.png) [@dwrenne](https://community.sparkfun.com/u/dwrenne)\
**Post date:** [December 11, 2006, 9:18pm UTC](https://community.sparkfun.com/t/new-avr-user-with-tiny2313-and-mega168-and-olimex-boards/3294/1 "2006-12-11T21:18:28Z")

</div>

Guys,

I bought a few 20 pin tiny2313 and few mega168 (28 pin) processors, the corresponding olimex boards and both a usb jtag programmer and an isp programmer from sparkfun

[http://www.sparkfun.com/commerce/produc … ucts\_id=12](http://www.sparkfun.com/commerce/product_info.php?products_id=12)

[http://www.sparkfun.com/commerce/produc … ucts\_id=14](http://www.sparkfun.com/commerce/product_info.php?products_id=14)

I have used avrstudio 4, bascom avr and ponyprog and none of them recognise the chips or boards or give any indication that there is anything on the cable. I am using the serial programmer as the olimex borads do not have a JTAG interface.

Is there some voodo that I have to do. Are there ANY step by step instructions other than a brezzy “works with ponyprog”.

Should I buy an stk500 or would that not help?

Thanks

Diarmuid

---

<div class="post-metadata">

**Author:** ![dwrenne](https://avatars.discourse-cdn.com/v4/letter/d/cab0a1/32.png) [@dwrenne](https://community.sparkfun.com/u/dwrenne)\
**Post date:** [December 11, 2006, 9:22pm UTC](https://community.sparkfun.com/t/new-avr-user-with-tiny2313-and-mega168-and-olimex-boards/3294/2 "2006-12-11T21:22:49Z")

</div>

PS

Actually I lie. I just tried it again with ponyprog , the 20 pin board with a tiny2313 and the power LED dimmed a few times in a second. so the software is seeing the board but thows up a “device missing or unknown device (-24)” error.

Hoping this helps

Diarmuid

---

<div class="post-metadata">

**Author:** ![stevech](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@stevech](https://community.sparkfun.com/u/stevech)\
**Post date:** [December 13, 2006, 5:53am UTC](https://community.sparkfun.com/t/new-avr-user-with-tiny2313-and-mega168-and-olimex-boards/3294/3 "2006-12-13T05:53:22Z")

</div>

one of the folks on [avrfreaks.net](http://avrfreaks.net) forum will know

---

<div class="post-metadata">

**Author:** ![dwrenne](https://avatars.discourse-cdn.com/v4/letter/d/cab0a1/32.png) [@dwrenne](https://community.sparkfun.com/u/dwrenne)\
**Post date:** [December 13, 2006, 12:07pm UTC](https://community.sparkfun.com/t/new-avr-user-with-tiny2313-and-mega168-and-olimex-boards/3294/4 "2006-12-13T12:07:31Z")

</div>

Fixed.

David Carne of Sparkfun sorted this for me. I used avrdude.exe in winavr (not the gui) and the following

C:\WinAVR\bin\>“avrdude” -p attiny2313 -c ponyser -P com6 -U flash:w:“C:\blinky\blinky.hex”:a -U flash✌“C:\blinky\blinky.hex”:a

The critical thing here is the programmer is **ponyser**. Also the 20 pin board would not program with the LED jumper connected. I used the Blinky.c program and the make file from WINAVR, copied them to c:\blinky, renamed the files to be all lower case, and modified the make file to reference the blinky.c file. I modified blinky.c to look like this

```auto
// Blinky.c
#include <avr/io.h>
#include <avr/delay.h>
int main (void)
{
// set PORTD for output
DDRB = 0xFF;
while(1) {
for(int i = 1; i <= 128; i = i*2)
{
PORTB = i;
_delay_loop_2(30000);
}
for(int i = 128; i > 1; i -= i/2)
{
PORTB = i;
_delay_loop_2(30000);
}
}
return 1;
}

```

so that it uses port B.

Make looked like this

```auto
# MCU name
MCU = attiny2313

# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the 
# processor frequency. You can then use this symbol in your source code to 
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
# automatically to create a 32-bit value in your source code.
# Typical values are:
# F_CPU = 1000000
# F_CPU = 1843200
# F_CPU = 2000000
# F_CPU = 3686400
# F_CPU = 4000000
# F_CPU = 7372800
# F_CPU = 8000000
# F_CPU = 11059200
# F_CPU = 14745600
# F_CPU = 16000000
# F_CPU = 18432000
# F_CPU = 20000000
F_CPU = 10000000

# Output format. (can be srec, ihex, binary)
FORMAT = ihex

# Target file name (without extension).
TARGET = blinky

# Object files directory
OBJDIR = obj

# List C source files here. (C dependencies are automatically generated.)
SRC = blinky.c

```

The blinky.c reference in the makefile was not in the file as it came from winavr examples. That took me a bit to figure out.

Changing the code and make file for the mega168 worked fine but the led port in C (AFAICR). make runs in under a second. The programming takes a few minutes. I am using a comfile [http://www.cubloc.com](http://www.cubloc.com) FBID based usb to serial converter , and it works fine.

Notice that I am using com6. When connected first, the virtual com port was number 30 something so I forced that to com6 in XP control panel.

Thanks again to Dave

Regards

Diarmuid

---

<div class="post-metadata">

**Author:** ![dwrenne](https://avatars.discourse-cdn.com/v4/letter/d/cab0a1/32.png) [@dwrenne](https://community.sparkfun.com/u/dwrenne)\
**Post date:** [December 15, 2006, 6:28pm UTC](https://community.sparkfun.com/t/new-avr-user-with-tiny2313-and-mega168-and-olimex-boards/3294/5 "2006-12-15T18:28:11Z")

</div>

I have started using Bascom-avr to see how that is and it allows an external programmer to be used

1. Open Bascom AVR

2. Click Options\>\>Programmer

3. Select “External programmer” in Programmer

4. Browse to C:\winavr\bin\avrdude.exe in Program

5. Enter -p attiny2313 -c ponyser -P com6 -U flash:w:“{FILE}”:a in Parameter

6. Enable ‘Use HEX file’

Change as appropriate for your processor and com port

Regards

Diarmuid
