at90pwm81-16se ATMEL Corporation, at90pwm81-16se Datasheet - Page 184

no-image

at90pwm81-16se

Manufacturer Part Number
at90pwm81-16se
Description
8-bit Avr Microcontroller With 8k Bytes In- System Programmable Flash
Manufacturer
ATMEL Corporation
Datasheet
15.3
15.3.1
184
SS Pin Functionality
AT90PWM81
Slave Mode
Note:
When the SPI is configured as a Slave, the Slave Select (SS) pin is always input. When SS is held low, the
SPI is activated, and MISO becomes an output if configured so by the user. All other pins are inputs.
When SS is driven high, all pins are inputs, and the SPI is passive, which means that it will not receive
incoming data. Note that the SPI logic will be reset once the SS pin is driven high.
Assembly Code Example
C Code Example
SPI_SlaveInit:
SPI_SlaveReceive:
void SPI_SlaveInit(void)
{
}
char SPI_SlaveReceive(void)
{
}
; Set MISO output, all others input
ldi
out
; Enable SPI
ldi
out
ret
; Wait for reception complete
sbis SPSR,SPIF
rjmp SPI_SlaveReceive
; Read received data and return
in
ret
/* Set MISO output, all others input */
DDR_SPI = (1<<DD_MISO);
/* Enable SPI */
SPCR = (1<<SPE);
/* Wait for reception complete */
while(!(SPSR & (1<<SPIF)))
/* Return data register */
return SPDR;
1. The example code assumes that the part specific header file is included.
;
r17,(1<<DD_MISO)
DDR_SPI,r17
r17,(1<<SPE)
SPCR,r17
r16,SPDR
(1)
(1)
7734M–AVR–03/10

Related parts for at90pwm81-16se