Motorola MSC8101 ADS User's Guide Page 225

  • Download
  • Add to my manuals
  • Print
  • Page
    / 346
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 224
Operating the SPI as a Master
Serial Peripheral Interface (SPI) 11-7
The following example shows the steps required to initialize the SPI as a master. The
master SPI drives the
SCLK signal. The assumptions underlying this example are:
IMM is a pointer to the MSC8101 registers in the PowerPC system bus address
spaces and is initialized to 0xF0000000.
SPIPRAM is a pointer to the SPI parameter RAM.
RxTxBD is a pointer to the buffer descriptors RxBD and TxBD.
One RxBD and one TxBD are used.
The steps in initializing the SPI as a master are as follows:
1. Configure port D for SPI.
In the master mode,
SPISEL is disabled while SPIMOSI, SPIMISO, and SPICLK are
enabled.
SPISEL must be configured as a GPIO. The PPARD, PDIRD, and
PSORD registers are configured as follows:
IMM->io_regs[PORT_D].ppar = 0x0000E000;
IMM->io_regs[PORT_D].pdir = 0x00001000;
IMM->io_regs[PORT_D].psor = 0x0000F000;
2. Assign a pointer to the SPI parameter RAM.
At location IMM + 0x89FC, SPI_BASE points to the SPI parameter RAM area,
which can be placed at any 64-byte aligned address in the dual-port RAM’s
general-purpose area (Banks 1–8 are located at IMM + 0x0 through IMM +
0x3FFF). In this example, assume that the SPI parameter RAM area resides in
Bank 8 at IMM + 0x3800.
IMM->pram.standard.spi[0] = 0x38;
IMM->pram.standard.spi[1] = 0x00;
3. Configure RBASE and TBASE.
Assume that there is one RxBD followed by one TxBD at the beginning of the
dual-port RAM and the RxBD starts at IMM+0. Since each buffer descriptor is
8-bytes, the TxBD starts at IMM+8.
SPIPRAM->rbase = 0x0000;
SPIPRAM->tbase = 0x0008;
4. Configure RFCR and TFCR.
SPIRAM->rfcr = 0x10;
SPIRAM->tfcr = 0x10;
5. Configure MRBLR.
Assume the maximum bytes per receive buffer is 16 bytes.
SPIRAM->mrblr = 0x0010;
Page view 224
1 2 ... 220 221 222 223 224 225 226 227 228 229 230 ... 345 346

Comments to this Manuals

No comments