AT90CAN128-16AE ATMEL Corporation, AT90CAN128-16AE Datasheet - Page 115

no-image

AT90CAN128-16AE

Manufacturer Part Number
AT90CAN128-16AE
Description
8-bit Avr Microcontroller With 128K Bytes of Isp Flash And CAN Controller.flash (Kbytes) 128 Vcc (V) 2.7-5.5 EEPROM (Kbytes) 4 SRAM (bytes) 4K CAN (mess. Obj.) 15
Manufacturer
ATMEL Corporation
Datasheet
Reusing the Temporary High
Byte Register
4250C–CAN–03/04
The following code examples show how to do an atomic write of the TCNTn Register
contents. Writing any of the OCRnx or ICRn Registers can be done by using the same
principle.
Note:
The assembly code example requires that the r17:r16 register pair contains the value to
be written to TCNTn.
If writing to more than one 16-bit register where the high byte is the same for all registers
written, then the high byte only needs to be written once. However, note that the same
rule of atomic operation described previously also applies in this case.
Assembly Code Example
C Code Example
TIM16_WriteTCNTn:
void TIM16_WriteTCNTn( unsigned int i )
{
}
; Save global interrupt flag
in
; Disable interrupts
cli
; Set TCNTn to r17:r16
sts TCNTnH,r17
sts TCNTnL,r16
; Restore global interrupt flag
out SREG,r18
ret
unsigned char sreg;
unsigned int i;
/* Save global interrupt flag */
sreg = SREG;
/* Disable interrupts */
_CLI();
/* Set TCNTn to i */
TCNTn = i;
/* Restore global interrupt flag */
SREG = sreg;
1. The example code assumes that the part specific header file is included.
r18,SREG
(1)
(1)
AT90CAN128
115

Related parts for AT90CAN128-16AE