Yahoo Groups archive

AVR-Chat

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

Thread

Re: Re: [AVR-Chat] Help needed on ATMEGA128 AND TIMER0

Re: Re: [AVR-Chat] Help needed on ATMEGA128 AND TIMER0

2006-02-25 by kishor lalu bande

dear friends
i have written following programm
for delay why it is not working.
my clock speed is 4Mz and and want use it for LCD display delays

void waitMS(unsigned long ulMS)
{
CLI(); // disable all interrupts
ulTick = ulMS;
SEI(); // re-enable interrupts
while (ulTick>0);
}

void timer1_init(void)
{
TCCR1B = 0x00; //stop
TCNT1H = 0xC6; //setup
TCNT1L = 0x67;
OCR1AH = 0x39;
OCR1AL = 0x99;
OCR1BH = 0x39;
OCR1BL = 0x99;
ICR1H = 0x39;
ICR1L = 0x99;
TCCR1A = 0x00;
TCCR1B = 0x01; //start Timer
}

// TIMER1 has overflowed
#pragma interrupt_handler timer1_ovf_isr:10
void timer1_ovf_isr(void)
{
TCNT1H = 0xC6;
TCNT1L = 0x67;
if (ulTick > 0)
ulTick--;
}


On Fri, 24 Feb 2006 Zack Widup wrote :
>There should be enough data in the AVR data sheet to do that. And there
>should be examples at the AVRFreaks website, if not at the Atmel website
>itself, on doing that.
>Zack
>On Fri, 24 Feb 2006, kishorbande wrote:
>> dear freinds
>>
>> i am using this controller from last 6 months.
>> i am want to generate accurate 1 sec and 1milisec delay routines.
>> i am using imagecraft c cross compiler.
>> please help me.
>>
>> regards
>> kishor
>>
>SPONSORED LINKS
>Atmel avr
>Microcontrollers
>Intel microprocessors
>Pic microcontrollers
>YAHOO! GROUPS LINKS
> Visit your group "
>AVR-Chat
>" on the web.
>
> To unsubscribe from this group, send an email to:
>
>AVR-Chat-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to the
>Yahoo! Terms of Service
>.



Re: [AVR-Chat] Help needed on ATMEGA128 AND TIMER0

2006-02-25 by David Kelly

On Feb 24, 2006, at 9:46 PM, kishor lalu bande wrote:

> i have written following programm
> for delay why it is not working.
> my clock speed is 4Mz and and want use it for LCD display delays
>
> void waitMS(unsigned long ulMS)
> {
>     CLI();          // disable all interrupts
>     ulTick = ulMS;
>     SEI();          // re-enable interrupts
>     while (ulTick>0);
> }

You don't show the definition of ulTick. It must be volatile.

As for timing I/O to LCD's, don't. Poll the LCD for its busy bit,  
while using a timer (such as your ulTick) to prevent an infinite loop  
if the LCD does not respond.

--
David Kelly N4HHE, dkelly@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.

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.