Mcspi usage Summary

Source: Internet
Author: User

1. mcspi controller structure


The SPI bus has a total of four signal lines (CLK clock line, CS chip line selection, Mosi main device output from the device input line, Miso main device input from the device output line, under the control of CLK, the master device and the slave device exchange data in two-way shift registers.

Generally, one or more mcspi (Multi-Channel serial interface) controllers are integrated into the CPU. The internal structure of the controller is 1-1. One controller has one or more channels, and each channel uses an independent register, and each channel corresponds to two DMA requests (read and write), and one intc interrupts the request. Fclk is a function clock, and the clock CLK is provided for Spi through the divider (the value of the divider is set through the Register), iclk is a bus clock, only this clock can be used to read and write the registers in the mcspi controller. The controller can be configured as the master device or slave device, as shown in figure 1-2 and Figure 1-3. The clock signal and chip selection signal are provided internally by the Controller as the master device, and externally provided as the slave device.

When mcspi is the master device, it can be configured as a single-channel operation and multi-channel operation. In single-channel operations, the chip selection signal can be configured as automatic output and software control output. In multi-channel operations, the chip selection signal can only be automatically output.


650) This. width = 650; "width =" 547 "Height =" 561 "Title =" image 1.png "style =" width: 517px; Height: 562px; float: none; "src =" http://s3.51cto.com/wyfs02/M01/4A/4D/wKiom1QkJc3h-iOSAAJ7SYcrUq4215.jpg "alt =" wKiom1QkJc3h-iOSAAJ7SYcrUq4215.jpg "/>

Figure 1-1



650) This. width = 650; "Title =" image 2.png "style =" float: none; "src =" http://s3.51cto.com/wyfs02/M00/4A/4F/wKioL1QkJfKhVp3lAACfnaW-Z2c841.jpg "alt =" wKioL1QkJfKhVp3lAACfnaW-Z2c841.jpg "/>

Figure 1-2



650) This. width = 650; "Title =" image 3.png "style =" float: none; "src =" http://s3.51cto.com/wyfs02/M02/4A/4F/wKioL1QkJfKgN207AACiq54_IAg862.jpg "alt =" wkiol1qkjfkgn207aaciq54_iag862.jpg "/>

Figure 1-3



2. mcspi controller Working Mode


As the mcspi controller of the main device, in order to exchange data with peripherals, the polarity and phase of the serial clock output by the main device can be configured according to the working requirements of peripherals. There are four modes as shown in Figure 2-1 and Figure 2-2.

650) This. width = 650; "width =" 848 "Height =" 243 "Title =" image 4.png "style =" width: 558px; Height: 239px; float: none; "src =" http://s3.51cto.com/wyfs02/M02/4A/4D/wKiom1QkJc6TunnHAAIbAL8cx_o435.jpg "alt =" wkiom1qkjc6tunnhaaibal8cx_o435.jpg "/>

Figure 2-1


650) This. width = 650; "Title =" image 5.png "style =" float: none; "src =" http://s3.51cto.com/wyfs02/M00/4A/4F/wKioL1QkJfOj70SeAADsf2DvHLk074.jpg "alt =" wkiol1qkjfoj70seaadsf2dvhlk074.jpg "/>

Figure 2-2


The clock polarity is used to configure the status when the synchronization clock is idle, which has no significant impact on the transmission protocol, and the clock phase is used to configure the transmission protocol of the SPI bus. If PHA is set to 0, the primary device and slave device prepare data immediately after the selected device is valid (the primary device moves the data to MoSi and the device moves the data to Miso ), output the clock signal after half a clock cycle, that is, sampling the first data along the first clock, as shown in Figure 2-3. If PHA = 1, after the slice is selected as valid, the clock signal starts to be output after the time tlead (the size of tlead can be configured through registers), and the data is output at the same time. After half a clock cycle, the data is ready, that is, the first data is sampled on the second clock edge, as shown in Figure 2-4.


650) This. width = 650; "width =" 604 "Height =" 314 "Title =" image 6.png "style =" width: 565px; Height: 320px; float: none; "src =" http://s3.51cto.com/wyfs02/M00/4A/4D/wKiom1QkJc7RKR8uAAH8rlJZvu0615.jpg "alt =" wkiom1qkjc7rkr8uaah8rljzvu0615.jpg "/>


Figure 2-3



650) This. width = 650; "width =" 635 "Height =" 335 "Title =" image 7.png "style =" width: 545px; Height: 335px; float: none; "src =" http://s3.51cto.com/wyfs02/M00/4A/4D/wKiom1QkJc-B_htcAAHcS8MQUbE538.jpg "alt =" wKiom1QkJc-B_htcAAHcS8MQUbE538.jpg "/>

Figure 2-4


3. Use


In use, you must configure the master device to one of the four modes based on the Mode Supported by the slave device.


Mcspi usage Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.