STC89C52MCU--Serial Communication Interface SPI

Publisher:心灵之窗Latest update time:2018-08-22 Source: eefocusKeywords:STC89C52  MCU  SPI Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

SPI is a full-duplex, high-speed, synchronous communication bus. It has two working modes: master mode and slave mode. In master mode, the transmission rate can reach 3mbps. When the system clock is 12Mhz, if the CPU uses a higher frequency, the rate can be higher. In slave mode, the speed cannot be too fast, usually within fsoc/8.

Data registers related to STC12 series microcontroller and SPI interface


nameaddressFunctional DescriptionD7D6D5D4D3D2D1D0
SPCTL85HSPI Control RegistersSSIGGPD0RDMSTRCP0LCPHASPR1SPR0
SPSTAT84HSPI fill registerSPIFWCOL





SPDAT86HSPI Data Register







SPCTL register function




SPSTAT register function


SPDAT.7 - SPDAT.0 -- Transmission data bits Bit7~Bit0


Looking at the SPI frame diagram, SPI has four pins: SPICLK/P1.7, MOSI/P1.5, MISO/P1.6, and SS/P1.4


The SPI clock divider selection is implemented through the SPR1 and SPR0 bits in SPCTL.

SPI write conflict: SPI is single buffered when transmitting and double buffered when receiving. If new data is written to the shift register when transmitting, WCOL will be set to indicate a data conflict; the written data will be lost and the data will continue to be sent. When the host or slave performs write conflict detection, the probability of a write conflict in the host is very low because the host has full control over the data transmission, but a write conflict may occur in the slave because the slave cannot control the transmission. When receiving data, the received data is transferred to a parallel read data buffer, which will release the shift register for the next data reception; but the received data must be read out before the next character is completely shifted in, otherwise the previous data will be lost.

For specific host connection configuration mode diagram, please refer to P299


Keywords:STC89C52  MCU  SPI Reference address:STC89C52MCU--Serial Communication Interface SPI

Previous article:89 Summary of C language preprocessing instructions
Next article:51 single chip microcomputer controlled temperature sensor DS18B20

Recommended ReadingLatest update time:2024-11-16 11:33

Keyboard circuit example analysis: Pull-up resistor error causes 51 MCU to fail to operate normally
In circuit design, in order to maintain the resistor clamp at a high level, pull-up resistors are used to stabilize the resistor, so pull-up resistors begin to appear in circuit design in large quantities. This article uses the keyboard circuit as an example to analyze a situation where the 51 microcontroller circuit
[Microcontroller]
Keyboard circuit example analysis: Pull-up resistor error causes 51 MCU to fail to operate normally
Create a new project for PIC microcontroller using MPLAB X IDE v5.00
1. After installing MPLAB X IDE v5.00, the compiler interface is as follows: 2. Create a new file: File - New Project   3. "Microchip Embedded" - "Standalone Project" - "Next"   4. Select a 16-bit microcontroller here, taking PIC32MM032GPL028 as an example. After selecting, click "NEXT".   5. Select the downlo
[Microcontroller]
Create a new project for PIC microcontroller using MPLAB X IDE v5.00
A/D Conversion of PIC Microcontroller
//A/D conversion //★★★★★★★★★A/D conversion ★★★★★★★★★★★★\\ //MCU model: PIC16F877A //Function description: Select RAO as the analog input channel; //Convert 5 times in a row and then calculate the average value as the conversion result //The final structure only takes the lower 8 bits //The result is sent to the
[Microcontroller]
Talking about MCU peripheral modules Part 2: How to improve ADC conversion accuracy
Here we briefly summarize how to understand the various indicators of ADC, and what means can be used from hardware to software to improve the conversion accuracy of ADC. 1.ADC indicators In addition to the basic indicators such as resolution, speed, and input range, the following indicators are usually used to meas
[Microcontroller]
Talking about MCU peripheral modules Part 2: How to improve ADC conversion accuracy
Design and implementation of sine wave inverter based on PIC microcontroller
At present, there are three main ways to generate SPWM signals: 1) Use analog circuits such as comparators and oscillators to generate triangular waves and square waves for comparison to generate SPWM waves. However, this method has complex circuits, is greatly affected by the accuracy of components, and is difficult
[Microcontroller]
Design and implementation of sine wave inverter based on PIC microcontroller
Infrared remote control motor speed control + Puzhong 51 single chip microcomputer + Jiangke University Automation Association
1 Experimental Phenomenon Design an infrared remote control DC motor speed control system based on STC89C52 single chip microcomputer. Once powered on, the digital tube displays 0, and the DC motor does not rotate. When the "1" key on the infrared remote control is pressed, the digital tube displays 1, an
[Microcontroller]
Infrared remote control motor speed control + Puzhong 51 single chip microcomputer + Jiangke University Automation Association
STC89C52RC serial port baud rate program
1. The complete code is as follows: C #include#define uchar unsigned char #define uint unsigned int void send(uchar state) { SBUF=state; while(TI==0); TI=0; } void SCON_init(void) { TMOD=0x20;//6T mode, 11.05992@115200 SCON=0x50; PCON=0x80; TL1=0xFF; TH1=0xFF; TR1=1; /*SCON=0x50;//Timer 2 mode, 11.0592@115200 TH2=0xFF
[Microcontroller]
Design and implementation of digital cursor direct reading oscilloscope based on single chip microcomputer
1 Introduction   The YB4365/4345 digital cursor direct reading oscilloscope is a national key new product in 2001. It is a broadband oscilloscope that uses single-chip microcomputer control technology and dual time base scanning technology. The machine not only has the function of a general oscilloscope, but also has
[Microcontroller]
Design and implementation of digital cursor direct reading oscilloscope based on single chip microcomputer
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号