109
8018P–AVR–08/10
ATmega169P
15.3
Accessing 16-bit Registers
The TCNT1, OCR1A/B, and ICR1 are 16-bit registers that can be accessed by the AVR CPU via
the 8-bit data bus. The 16-bit register must be byte accessed using two read or write operations.
Each 16-bit timer has a single 8-bit register for temporary storing of the high byte of the 16-bit
access. The same temporary register is shared between all 16-bit registers within each 16-bit
timer. Accessing the low byte triggers the 16-bit read or write operation. When the low byte of a
16-bit register is written by the CPU, the high byte stored in the temporary register, and the low
byte written are both copied into the 16-bit register in the same clock cycle. When the low byte of
a 16-bit register is read by the CPU, the high byte of the 16-bit register is copied into the tempo-
rary register in the same clock cycle as the low byte is read.
Not all 16-bit accesses uses the temporary register for the high byte. Reading the OCR1A/B 16-
bit registers does not involve using the temporary register.
To do a 16-bit write, the high byte must be written before the low byte. For a 16-bit read, the low
byte must be read before the high byte.
The following code examples show how to access the 16-bit Timer Registers assuming that no
interrupts updates the temporary register. The same principle can be used directly for accessing
the OCR1A/B and ICR1 Registers. Note that when using “C”, the compiler handles the 16-bit
access.
Note:
The assembly code example returns the TCNT1 value in the r17:r16 register pair.
It is important to notice that accessing 16-bit registers are atomic operations. If an interrupt
occurs between the two instructions accessing the 16-bit register, and the interrupt code
updates the temporary register by accessing the same or any other of the 16-bit Timer Regis-
ters, then the result of the access outside the interrupt will be corrupted. Therefore, when both
Assembly Code Examples(1)
...
; Set TCNT
1 to 0x01FF
ldi
r17,0x01
ldi
r16,0xFF
out
TCNT
1H,r17
out
TCNT
1L,r16
; Read TCNT
1 into r17:r16
in
r16,TCNT
1L
in
r17,TCNT
1H
...
C Code Examples(1)
unsigned int
i;
...
/* Set TCNT
1 to 0x01FF */
TCNT
1 = 0x1FF;
/* Read TCNT
1 into i */
i = TCNT
1;
...
相关PDF资料
ATMEGA169P-16MCU MCU AVR 16K ISP FLSH 16MHZ 64QFN
AT91SAM7XC256-CU MCU ARM 256K HS FLASH 100-TFBGA
PIC16LF874A-I/P IC MCU FLASH 4KX14 EE A/D 40DIP
PIC16F84-10/SO IC MCU FLASH 1KX14 EE 18SOIC
AT91SAM7XC128-CU MCU ARM 128K HS FLASH 100-TFBGA
PIC18F2458-I/SO IC PIC MCU FLASH 12KX16 28SOIC
PIC18F4455-I/P IC PIC MCU FLASH 12KX16 40DIP
AT91SAM7X256-CU MCU ARM 256K HS FLASH 100-TFBGA
相关代理商/技术参数
ATMEGA169PV-8MU 功能描述:8位微控制器 -MCU AVR 16K FLASH 512B EE 1K SRAM 5V RoHS:否 制造商:Silicon Labs 核心:8051 处理器系列:C8051F39x 数据总线宽度:8 bit 最大时钟频率:50 MHz 程序存储器大小:16 KB 数据 RAM 大小:1 KB 片上 ADC:Yes 工作电源电压:1.8 V to 3.6 V 工作温度范围:- 40 C to + 105 C 封装 / 箱体:QFN-20 安装风格:SMD/SMT
ATMEGA169PV-8MU SL383 制造商:Atmel Corporation 功能描述:MCU 8BIT ATMEGA RISC 16KB FLASH 2.5V/3.3V/5V 64PIN MLF - Tape and Reel
ATMEGA169PV-8MU 制造商:Atmel Corporation 功能描述:IC 8BIT MCU AVR MEGA 8MHZ 64-QFN
ATMEGA169PV-8MUR 功能描述:8位微控制器 -MCU AVR LCD 16KB FLSH EE 512B 1KB SRAM-8MHZ RoHS:否 制造商:Silicon Labs 核心:8051 处理器系列:C8051F39x 数据总线宽度:8 bit 最大时钟频率:50 MHz 程序存储器大小:16 KB 数据 RAM 大小:1 KB 片上 ADC:Yes 工作电源电压:1.8 V to 3.6 V 工作温度范围:- 40 C to + 105 C 封装 / 箱体:QFN-20 安装风格:SMD/SMT
ATMEGA169V 制造商:ATMEL 制造商全称:ATMEL Corporation 功能描述:8-bit Microcontroller with 16K Bytes In-System Programmable Flash
ATMEGA169V_06 制造商:ATMEL 制造商全称:ATMEL Corporation 功能描述:8-bit Microcontroller with 16K Bytes In-System Programmable Flash
ATMEGA169V-1AC 功能描述:IC MCU 8BIT 16KB FLASH 64TQFP 制造商:microchip technology 系列:AVR? ATmega 包装:托盘 零件状态:停產 核心处理器:AVR 核心尺寸:8-位 速度:1MHz 连接性:SPI,UART/USART,USI 外设:欠压检测/复位,LCD,POR,PWM,WDT I/O 数:53 程序存储容量:16KB(8K x 16) 程序存储器类型:闪存 EEPROM 容量:512 x 8 RAM 容量:1K x 8 电压 - 电源(Vcc/Vdd):1.8 V ~ 5.5 V 数据转换器:A/D 8x10b 振荡器类型:内部 工作温度:0°C ~ 70°C 封装/外壳:64-TQFP 供应商器件封装:64-TQFP(14x14) 基本零件编号:ATmega169 标准包装:160
ATMEGA169V-1AI 制造商:ATMEL 制造商全称:ATMEL Corporation 功能描述:8-bit AVR Microcontroller with 16K Bytes In-System Programmable Flash