Rainbow-electronics ATmega128RFA1 User Manual Page 333

  • Download
  • Add to my manuals
  • Print
  • Page
    / 524
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 332
333
8266A-MCU Wireless-12/09
ATmega128RFA1
C Code Example
(1)
void SPI_MasterInit(void)
{
/* Set MOSI and SCK output, all others input */
DDR_SPI = (1<<DD_MOSI)|(1<<DD_SCK);
/* Enable SPI, Master, set clock rate fck/16 */
SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);
}
void SPI_MasterTransmit(char cData)
{
/* Start transmission */
SPDR = cData;
/* Wait for transmission complete */
while(!(SPSR & (1<<SPIF)))
;
}
Note: 1. See "About Code Examples" on page 7
Assembly Code Example
(1)
SPI_SlaveInit:
; Set MISO output, all others input
ldi r17,(1<<DD_MISO)
out DDR_SPI,r17
; Enable SPI
ldi r17,(1<<SPE)
out SPCR,r17
ret
SPI_SlaveReceive:
; Wait for reception complete
sbis SPSR,SPIF
rjmp SPI_SlaveReceive
; Read received data and return
in r16,SPDR
ret
Page view 332
1 2 ... 328 329 330 331 332 333 334 335 336 337 338 ... 523 524

Comments to this Manuals

No comments

Second Wind Luftfilter Benutzerhandbücher

Beginnend mit N

Klicken Sie auf den Alphabet unten, um zur vollständigen Liste der Modelle zu gelangen, die mit diesem Buchstaben beginnen

Modelle Dokumententyp
Noble 6018
Installationshandbuch   Second Wind Noble 6018 Unit installation, 10 Seiten