Yahoo Groups archive

AVR-Chat

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

Thread

Timer1 error

Timer1 error

2007-11-21 by twrokspit

Hi. Everyone

I have an error reading the TCNT1L, TCNT1H from the 16-bit counter, im 
using the ICP1 and when this causes an interruption the High and Low 
bits of the counter must be read.

When i try to assemble the project i got i message which says

operand 2 out of range and gives me the address of the counter registers

in r6,TCNT1L
in r7,TCNT1H

I will acknowledge any help

Re: [AVR-Chat] Timer1 error

2007-11-23 by David Kelly

On Nov 21, 2007, at 1:21 PM, twrokspit wrote:

> I have an error reading the TCNT1L, TCNT1H from the 16-bit counter, im
> using the ICP1 and when this causes an interruption the High and Low
> bits of the counter must be read.
>
> When i try to assemble the project i got i message which says
>
> operand 2 out of range and gives me the address of the counter  
> registers
>
> in r6,TCNT1L
> in r7,TCNT1H


The input capture hardware is supposed to do that job for you. It  
*captures* the timer value when the ICP1 pin changes. A copy of TCNT1  
at the instant of ICP1 should be in ICR1 depending on how you  
configured the input capture system. You could then subtract ICR1 from  
TCNT1 to determine how long ago the event happened.

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

Re: [AVR-Chat] Timer1 error

2007-11-23 by John Samperi

At 06:21 AM 22/11/2007, you wrote:
>operand 2 out of range and gives me the address of the counter registers
>
>in r6,TCNT1L
>in r7,TCNT1H

Depending on which processor you are using, TCNT1 could be
memory mapped and therefore you need to use LDS and STS
instead of IN/OUT.

You can also use a macro from AVR001 LOAD and STORE and it
will automatically switch in the correct instruction.

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Email: john@ampertronics.com.au
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

Re: [AVR-Chat] Timer1 error

2007-11-27 by Pedro Ayala Muñoz

Thank you so much John. 

Using the LDS instruction my problem was solved.
Absolutely the operand was out of range because in the ATmega169P 
the address is higher than 63 for the timer1 counter registers wish is not supported by the "IN" instruction.

Reference:Page 79, AVR instruction set.


John Samperi <samperi@ampertronics.com.au> escribió:                               At 06:21 AM 22/11/2007, you wrote:
 >operand 2 out of range and gives me the address of the counter registers
 >
 >in r6,TCNT1L
 >in r7,TCNT1H
 
 Depending on which processor you are using, TCNT1 could be
 memory mapped and therefore you need to use LDS and STS
 instead of IN/OUT.
 
 You can also use a macro from AVR001 LOAD and STORE and it
 will automatically switch in the correct instruction.
 
 Regards
 
 John Samperi
 
 ********************************************************
 Ampertronics Pty. Ltd.
 11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
 Tel. (02) 9674-6495       Fax (02) 9674-8745
 Email: john@ampertronics.com.au
 Website  http://www.ampertronics.com.au
 *Electronic Design * Custom Products * Contract Assembly
 ********************************************************
 
 
     
                               

       
---------------------------------

¡Capacidad ilimitada de almacenamiento en tu correo!
No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:
http://correo.yahoo.com.mx/

[Non-text portions of this message have been removed]

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.