EasyManuals Logo

Atmel AVR AT90CAN32 User Manual

Atmel AVR AT90CAN32
428 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #118 background imageLoading...
Page #118 background image
118
7679H–CAN–08/08
AT90CAN32/64/128
The following code examples show how to do an atomic read of the TCNTn Register contents.
Reading any of the OCRnx or ICRn 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 TCNTn value in the r17:r16 register pair.
Assembly Code Example
(1)
TIM16_ReadTCNTn:
; Save global interrupt flag
in r18,SREG
; Disable interrupts
cli
; Read TCNTn into r17:r16
lds r16,TCNTnL
lds r17,TCNTnH
; Restore global interrupt flag
out SREG,r18
ret
C Code Example
(1)
unsigned int TIM16_ReadTCNTn(void)
{
unsigned char sreg;
unsigned int i;
/* Save global interrupt flag */
sreg = SREG;
/* Disable interrupts */
_CLI();
/* Read TCNTn into i */
i = TCNTn;
/* Restore global interrupt flag */
SREG = sreg;
return i;
}

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Atmel AVR AT90CAN32 and is the answer not in the manual?

Atmel AVR AT90CAN32 Specifications

General IconGeneral
BrandAtmel
ModelAVR AT90CAN32
CategoryMicrocontrollers
LanguageEnglish

Related product manuals