202
8018P–AVR–08/10
ATmega169P
rjmp
SPITransfer_loop
lds
r16,USIDR
ret
The code is size optimized using only eight instructions (+ ret). The code example assumes that
the DO and USCK pins are enabled as output in the DDRE Register. The value stored in register
r16 prior to the function is called is transferred to the Slave device, and when the transfer is com-
pleted the data received from the Slave is stored back into the r16 Register.
The second and third instructions clears the USI Counter Overflow Flag and the USI counter
value. The fourth and fifth instruction set Three-wire mode, positive edge Shift Register clock,
count at USITC strobe, and toggle USCK. The loop is repeated 16 times.
The following code demonstrates how to use the USI module as a SPI Master with maximum
speed (fsck = fck/4):
SPITransfer_Fast:
sts
USIDR,r16
ldi
r16,(1<<USIWM0)|(0<<USICS0)|(1<<USITC)
ldi
r17,(1<<USIWM0)|(0<<USICS0)|(1<<USITC)|(1<<USICLK)
sts
USICR,r16 ; MSB
sts
USICR,r17
sts
USICR,r16
sts
USICR,r17
sts
USICR,r16
sts
USICR,r17
sts
USICR,r16
sts
USICR,r17
sts
USICR,r16
sts
USICR,r17
sts
USICR,r16
sts
USICR,r17
sts
USICR,r16
sts
USICR,r17
sts
USICR,r16 ; LSB
sts
USICR,r17
lds
r16,USIDR
ret
相关PDF资料
PIC16C716-20I/P IC MCU OTP 2KX14 A/D PWM 18DIP
PIC18F26K80-I/SO MCU PIC 64KB FLASH 28SOIC
PIC18F26J13-I/SS IC PIC MCU 64KB FLASH 28SSOP
SFW27R-1STE1 SFW27R-1STE1-FFC/FPC CONN
PIC18F66J15-I/PT IC PIC MCU FLASH 48KX16 64TQFP
PIC24FV32KA302-I/SO MCU 32KB FLASH 2KB RAM 28-SOIC
PIC24HJ64GP204-I/ML IC PIC MCU FLASH 64K 44-QFN
SFW27R-2STE1 SFW27R-2STE1-FFC/FPC CONN
相关代理商/技术参数
PIC16F916-I/SO 功能描述:8位微控制器 -MCU 14KB FL 352R 25 I/O 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
PIC16F916-I/SO 制造商:Microchip Technology Inc 功能描述:8 Bit Microcontroller Clock Speed:20MHz
PIC16F916-I/SOG 制造商:Microchip Technology Inc 功能描述:8BIT MCU FLASH SMD 16F916 SOIC28
PIC16F916-I/SP 功能描述:8位微控制器 -MCU 14KB FL 352R 25 I/O 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
PIC16F916-I/SP 制造商:Microchip Technology Inc 功能描述:8 Bit Microcontroller Clock Speed:20MHz
PIC16F916-I/SS 功能描述:8位微控制器 -MCU 14KB FL 352R 25 I/O 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
PIC16F916-I/SS 制造商:Microchip Technology Inc 功能描述:8-Bit Microcontroller IC
PIC16F916T-E/MLC02 制造商:Microchip Technology Inc 功能描述: