+ Reply to Thread
Results 1 to 4 of 4

Thread: AVR Info

  1. #1
    AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent
    Join Date
    Feb 2008
    Location
    Brooklyn, NY US
    Posts
    3,738

    Default AVR Info

    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

    Code:
    Delay200mS:                ;delay 202mS at 9.6mhz 
        ldi  d2, 0x13
    repeatd2:
        dec  d2
        ldi  d1, 0xFC
    delay200ms_1:
        dec  d1
        cpi  d1,0x00
        brne delay200ms_1
        cpi  d2,0x00
        brne repeatd2
        ret
    
    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?
    AtomSofts eBay Store
    AtomSoftTech: C18 TIPS & TRICKS v9 PDF

    My Name: Jason Lopez
    My BLOG | My YouTube Videos!
    My Favorite Store:
    dipmicro Electronics
    Trading and Selling...? Check out Dipmicro Trading/Selling Forum:
    Electronic Components & Tools Exchange


  2. #2
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,759

    Default

    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.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  3. #3
    AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent
    Join Date
    Feb 2008
    Location
    Brooklyn, NY US
    Posts
    3,738

    Default

    oh i even forgot about that lol thanks a ton Nigel!
    AtomSofts eBay Store
    AtomSoftTech: C18 TIPS & TRICKS v9 PDF

    My Name: Jason Lopez
    My BLOG | My YouTube Videos!
    My Favorite Store:
    dipmicro Electronics
    Trading and Selling...? Check out Dipmicro Trading/Selling Forum:
    Electronic Components & Tools Exchange

  4. #4
    AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent
    Join Date
    Feb 2008
    Location
    Brooklyn, NY US
    Posts
    3,738

    Default

    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.)
    Code:
    Delay200uS:                ;delay 199.27uS at 9.6mhz 
        ldi     d1, $07
    L2:
        ldi     d2, $5A
    L3:
        dec     d2         
        brne    L3        
        dec     d1         
        brne    L2        
        nop
        nop
        ret
    
    I used this generator:
    http://www.home.unix-ag.org/tjabo/avr/dlg_02/dlg02.php

    They have the source here(i think):
    http://www.home.unix-ag.org/tjabo/av.../src_coder.php
    Last edited by AtomSoft; 2nd June 2009 at 03:51 PM.
    AtomSofts eBay Store
    AtomSoftTech: C18 TIPS & TRICKS v9 PDF

    My Name: Jason Lopez
    My BLOG | My YouTube Videos!
    My Favorite Store:
    dipmicro Electronics
    Trading and Selling...? Check out Dipmicro Trading/Selling Forum:
    Electronic Components & Tools Exchange

+ Reply to Thread

Similar Threads

  1. Info about KEC 168 ???
    By arustu in forum General Electronics Chat
    Replies: 2
    Latest: 3rd August 2006, 06:55 PM
  2. Need info
    By shermaine in forum General Electronics Chat
    Replies: 3
    Latest: 13th May 2004, 04:31 AM
  3. PLC info?
    By cool-agent in forum General Electronics Chat
    Replies: 1
    Latest: 12th December 2003, 03:39 PM
  4. IR Info...
    By surjo_dm in forum General Electronics Chat
    Replies: 11
    Latest: 27th November 2003, 10:04 AM
  5. Where can I get more info on..
    By kevinloh in forum General Electronics Chat
    Replies: 0
    Latest: 31st October 2003, 12:02 PM

Tags for this Thread