Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

RE: [AVR-Chat] delay loop

2005-04-05 by wbounce

You would need to set up a timer. This is my timer0 init code from a m128 16MHZ
* Initialize timer0 to generate an output compare interrupt, and
* set the output compare register so that we get that interrupt
* every millisecond.
*/
TIFR |= BV(OCIE0);
TCCR0 = BV(WGM01)|BV(CS02)|BV(CS00); /* CTC, prescale = 128 */
TCNT0 = 0;
TIMSK |= BV(OCIE0); /* enable output compare interrupt */

OCR0 = MS_OCRMATCH; /* match in 1 ms normal value = 125 */
The formula is
clock io
------------
N * 256 where N = 1,8,32,64,128,256,1024
to figure out what N you need
1st do 8000000/256=31250
31250/150 = 208 which is between 128 and 256.
-----Original Message-----
From: rohan we [mailto:r143magick@yahoo.com]
Sent: Tuesday, April 05, 2005 2:53 AM
To: AVR-Chat@yahoogroups.com
Subject: [AVR-Chat] delay loop

Hi i am new in winavr i need to set a delay of 150hz i am using a 8Mhz clock
Help me


Do you Yahoo!?
Better first dates. More second dates. Yahoo! Personals

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.