ATmega88PA Automotive Atmel Corporation, ATmega88PA Automotive Datasheet - Page 170

no-image

ATmega88PA Automotive

Manufacturer Part Number
ATmega88PA Automotive
Description
Manufacturer
Atmel Corporation
170
Atmel ATmega48PA/88PA/168PA [Preliminary]
The following code examples show how to initialize the SPI as a Slave and how to perform a
simple reception.
Assembly Code Example
C Code Example
Note:
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
in r16, SPSR
sbrs r16, 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.
See ”About Code Examples” on page 7.
r17,(1<<DD_MISO)
DDR_SPI,r17
r17,(1<<SPE)
SPCR,r17
r16,SPDR
(1)
(1)
9223B–AVR–09/11

Related parts for ATmega88PA Automotive