Atmega8515(l) – Rainbow Electronics ATmega8515L User Manual
Page 98
98
ATmega8515(L)
2512A–AVR–04/02
The following code examples show how to do an atomic read of the TCNT1 Register
contents. Reading any of the OCR1A/B or ICR1 Registers can be done by using the
same principle.
Note:
1. The example code assumes that the part specific header file is included.
The assembly code example returns the TCNT1 value in the r17:r16 register pair.
Assembly Code Example
TIM16_ReadTCNT
1:
;
Save global interrupt flag
in
r18,SREG
;
Disable interrupts
cli
; Read TCNT
1 into r17:r16
in
r16,TCNT
1L
in
r17,TCNT
1H
;
Restore global interrupt flag
out
SREG,r18
ret
C Code Example
unsigned int
TIM16_ReadTCNT
1( void )
{
unsigned char
sreg;
unsigned int
i;
/*
Save global interrupt flag */
sreg = SREG;
/*
Disable interrupts */
_CLI();
/*
Read TCNT
1 into i */
i = TCNT
1;
/*
Restore global interrupt flag */
SREG = sreg;
return
i;
}
- MAX5151 (16 pages)
- MAXQ3108 (64 pages)
- MAX5661 (39 pages)
- MAX6691 (7 pages)
- MAX5362 (12 pages)
- ADC10158 (26 pages)
- MAX8922L (14 pages)
- MAX8596Z (8 pages)
- MAX7491 (18 pages)
- MAX15040 (15 pages)
- MAX5177 (16 pages)
- ADC08138 (22 pages)
- MAX5961 (42 pages)
- T89C51RD2 (86 pages)
- MAX16055 (9 pages)
- MAX6659 (17 pages)
- ADC0820 (20 pages)
- MAX6678 (19 pages)
- MAX8884Z (15 pages)
- MAX16915 (9 pages)
- MAX8620 (18 pages)
- MAX5144 (12 pages)
- MAX6670 (8 pages)
- MAX8760 (39 pages)
- W78C32C (14 pages)
- MX7533 (8 pages)
- MAX8727 (13 pages)
- MAX9053 (15 pages)
- W78C54 (16 pages)
- MAX8614B (15 pages)
- W90N740 (219 pages)
- MAX6626 (13 pages)
- ADC10738 (30 pages)
- MAX17000 (31 pages)
- MAX5051 (21 pages)
- MAXQ1004 (18 pages)
- MAX6871 (51 pages)
- MX7847 (12 pages)
- MAX6608 (6 pages)
- MAX17083 (15 pages)
- MAX6641 (17 pages)
- MAX5251 (16 pages)
- MAX6338 (8 pages)
- MAX6690 (16 pages)
- MAX8668 (18 pages)