• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

AVR Info

Not open for further replies.


Well-Known Member
hey guys im playing with some avr code and am really confused about the MIPS thing.

I found out that the TINY13 can do 9.6 MHZ easy. Now in a PDF from ATMEL they claim there 9.6 MHZ is 9.8 MIPS which i dont care.

Now if its 9.8MIPS if i divide it by 1000 (1 second) that makes it

9800 Instructions for 1 millisecond correct?
So 200 Milliseconds should be 9800 * 200 = 1,960,000 Instructions

So 200mS = 1,960,000 instructions right?

How come in AVR Studio im doing a loop for 200mS using the below code

Delay200mS:                ;delay 202mS at 9.6mhz 
    ldi  d2, 0x13
    dec  d2
    ldi  d1, 0xFC
    dec  d1
    cpi  d1,0x00
    brne delay200ms_1
    cpi  d2,0x00
    brne repeatd2
This should only delay about 4788 Instructions. This seems to give me about 202mS of delay time which is ok but why is the above math wrong?

in the Cycle Counter it says the delay took 19253 Cycles to complete.

Is the clock split in anyway? or what am i missing here?

Nigel Goodwin

Super Moderator
Most Helpful Member
You're possibly assuming an AVR is like a PIC, where almost all instructions take one cycle, on most other processors instructions mostly take multiple cycles, and the number of cycles varies from one instruction to another.

The datasheet should tell you how long each instruction takes - I've no idea on an AVR.

You might also see if you can download a delay code program, that generates the code for you - like you can for PIC's.


Well-Known Member
Nigel dont laugh lol i was thinking wrong also lol i wanted a 200us delay not ms and kept confusing them lol

New code:
(i had to alter it a bit it was ugly lol also i had to change the 5B to 5A and 06 to 07 to give me closer result.)
Delay200uS:                ;delay 199.27uS at 9.6mhz 
    ldi     d1, $07
    ldi     d2, $5A
    dec     d2         
    brne    L3        
    dec     d1         
    brne    L2        
I used this generator:

They have the source here(i think):
Last edited:
Not open for further replies.

Latest threads

EE World Online Articles