NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

StarterWare McSPI

From Texas Instruments Wiki
Jump to: navigation, search

Introduction[edit]

McSPI is a general-purpose receive/transmit, master/slave controller that can interface with up to four slave external devices or one single external master. It allows a duplex, synchronous, serial communication between CPU and SPI compliant external devices (Slaves and Masters). It supports maximum frequency of 48MHz. McSPI could be configured to generate DMA event to EDMA controller for transfer of data.

Programming sequence[edit]

Interrupt Mode[edit]

Configuring McSPI in master mode with Chip Select[edit]
  • Clocks for McSPI peripheral are enabled using the function McSPI0ModuleClkConfig() .
  • Pin muxing for SPI_CLK, SPI_D0, SPI_D1 pins can be done by calling the function McSPIPinMuxSetup().
  • Pin muxing for chip select(CS) is done by using the function McSPI0CSPinMuxSetup().
  • McSPI is placed in local reset state by using McSPIReset() API.
  • McSPI can be configured in 4-pin mode(CLK, D0, D1, CS) by using McSPICSEnable() API.
  • McSPI is enabled in Master mode of operation using the McSPIMasterModeEnable() API.
  • To configure Single/Multi channel mode, transmit/receive modes and settings for IS, DPE0, DPE1 can be done by using the McSPIMasterModeConfig() API. The settings for IS, DPE0 and DPE1 will configure the direction for SPID0 and SPID1 pins as input or output. Please refer to the schematics to verify the SPI data pin connections and do the setting accordingly. This API will return “FALSE” if an invalid configuration is done for IS,DPE0 and DPE1 pins which the McSPI controller cannot process.
  • McSPI clock configuration is done using the McSPIClkConfig() API. Granularity settings of 1 clock cycle or 2^n clock cycles can be done in this API. Also phase and polarity of McSPI clock can be configured here.
  • McSPI word length is configured using the McSPIWordLengthSet() API.
  • Polarity of SPIEN(chip select) is configured using McSPICSPolarityConfig() API.
  • To enable/disable the transmitter and receiver FIFOs the user can use McSPITxFIFOConfig() and McSPIRxFIFOConfig() APIs.
  • The SPIEN line is forced to the required polarity level(active state) by using the McSPICSAssert() API.
  • Enable the required interrupts by using the McSPIIntEnable() API.
  • Enable the required McSPI channel by using the McSPIChannelEnable() API. Once this API is called McSPI can generate interrupts depending on the setting.
  • Status on any interrupts can be got by using the McSPIIntStatusGet() API.
  • Status of any interrupts can be cleared by using the McSPIIntStatusClear() API.
  • Data to be transmitted from the McSPI peripheral is done using the McSPITransmitData() API.
  • Data can be read or received by using the McSPIReceiveData() API.
  • McSPI interrupts can be disabled by sending the necessary flags to the McSPIIntDisable() API.
  • The SPIEN line is forced to the inactive state by using the McSPICSDeAssert() API.
  • Disabling of McSPI channel can be done by using McSPIChannelDisable() API.

DMA Mode[edit]

Configuring McSPI in master mode with Chip Select[edit]
  • In DMA mode of operation, the data transfer happens via EDMA.
  • Clocks for McSPI peripheral are enabled using the function McSPI0ModuleClkConfig().
  • Pin muxing for SPI_CLK, SPI_D0, SPI_D1 pins can be done by calling the function McSPIPinMuxSetup().
  • Pin muxing for chip select(CS) is done by using the function McSPI0CSPinMuxSetup().
  • Clocks for EDMA peripheral are enabled using the EDMAModuleClkConfig() API.
  • Initialize the EDMA by calling the EDMA3Init() API.
  • Channels for McSPI Tx and Rx event can be requested to the EDMA3CC by calling the EDMA3RequestChannel API.
  • McSPI is placed in local reset state by using McSPIReset() API.
  • McSPI can be configured in 4-pin mode(CLK, D0, D1, CS) by using McSPICSEnable() API.
  • McSPI is enabled in Master mode of operation using the McSPIMasterModeEnable() API.
  • To configure Single/Multi channel mode, transmit/receive modes and settings for IS, DPE0, DPE1 can be done by using the McSPIMasterModeConfig() API. The settings for IS, DPE0 and DPE1 will configure the direction for SPID0 and SPID1 pins as input or output. Please refer to the schematics to verify the SPI data pin connections and do the setting accordingly. This API will return “FALSE” if an invalid configuration is done for IS,DPE0 and DPE1 pins which the McSPI controller cannot process.
  • McSPI clock configuration is done using the McSPIClkConfig() API. Granularity settings of 1 clock cycle or 2^n clock cycles can be done in this API. Also phase and polarity of McSPI clock can be configured here.
  • McSPI word length is configured using the McSPIWordLengthSet() API.
  • Polarity of SPIEN(chip select) is configured using McSPICSPolarityConfig() API.
  • To enable/disable the transmitter and receiver FIFOs the user can use McSPITxFIFOConfig() and McSPIRxFIFOConfig() APIs.
  • Transfer parameters for any specific event of EDMA3 controller is set by using EDMA3SetPaRAM() API. Transfer parameters for both transmit as well as receive have to be set because McSPI is a transceiver device.
  • Transfer from EDMA can be started by calling the EDMA3EnableTransfer API.
  • By using the McSPIWordCountSet() API the user can keep a count of number of SPI words to be transmitted. Once full transfer is done the count in the McSPI Transfer level register should go to zero.
  • The SPIEN line is forced to the required polarity level(active state) by using the McSPICSAssert() API.
  • McSPI-EDMA events (transmit/receive) are enabled by calling the McSPIDMAEnable() API.
  • Enable the required McSPI channel by using the McSPIChannelEnable() API. Once this API is called McSPI can generate EDMA events depending on the setting. A transmit empty register condition will generate a transmit EDMA event. A receive register full condition will generate a receive EDMA event.
  • The EDMA completion interrupt occurs the no. of bytes configured in the Param Set are exhausted.
  • Status of EDMA interrupts is got by using the EDMA3GetIntrStatus() API.
  • When the transfer is completed the EDMA event generation by McSPI is disabled using the McSPIDMADisable() API.
  • The SPIEN line is forced to the inactive state by using the McSPICSDeAssert() API.
  • Disabling of McSPI channel can be done by using McSPIChannelDisable() API.

NOTE
It is advisable to use the dummy transfer concept while handling McSPI Transmit events. This is because if a transmit event occurs from the McSPI to the EDMA, the EDMA will start transferring the bytes to the transmit register/FIFO of McSPI and hence the EDMA param set for Tx event will get depleted. The data from the transmit register/FIFO is immediately sent to slave device. Once the McSPI register/FIFO is empty the McSPI will generate a transmit event to the EDMA and since the EDMA param set is 0 the EDMA will not be able to service this event and a missed event will be generated which will be handled by the EDMA error handler. Hence to avoid this missed event the concept of dummy transfer can be used. In this concept a dummy PaRAM-Set is linked to the PaRAM-Set of the previous transmit event. This is done by giving the address of a dummy PaRAM-Set as the link address of transmit PaRAM-Set.

E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article StarterWare McSPI here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article StarterWare McSPI here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article StarterWare McSPI here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article StarterWare McSPI here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article StarterWare McSPI here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article StarterWare McSPI here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article StarterWare McSPI here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article StarterWare McSPI here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article StarterWare McSPI here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity