timeravravr-studio4

Getting value from TCNT0 AVR


I have a timer which increments by one every 256 cycles. Is there a way that i can get the value from TCNT0 at the point it is called.

I am using AVR Studio 4 and have tried using ldi temp, TCNT0 but i always seem to get 32 which is its address.

Thanks


Solution

  • If TCNT0 is within I/O space then you can use IN to retrieve its value, otherwise you will need to use LDS to load it from its memory address (which is usually offset by 0x20 from the I/O register location).

    in tmp,TCNT0