| Electronic Components Datasheet Search |
|
STC12LE5616AD Datasheet(PDF) 299 Page - STCmicro Technology Co,.Ltd |
|
|
|||||||||||||||||||||||||||||
STC12LE5616AD Datasheet(HTML) 299 Page - STCmicro Technology Co,.Ltd |
|
299 / 377 page ![]() 11.5.2 SPI Function Demo Programs using Polling 1. C code listing: /*--------------------------------------------------------------------------------------------*/ /* --- STC MCU International Limited -----------------------------------------------*/ /* --- STC12C5Axx Series MCU SPI Demo(Each other as the master-slave) --*/ /* If you want to use the program or the program referenced in the --------------*/ /* article, please specify in which data and procedures from STC --------------*/ /*---------------------------------------------------------------------------------------------*/ #include "reg51.h" #define FOSC 18432000L #define BAUD (256 - FOSC / 32 / 115200) typedef unsigned char BYTE; typedef unsigned int WORD; typedef unsigned long DWORD; sfr AUXR = 0x8e; //Auxiliary register sfr SPSTAT = 0x84; //SPI status register #define SPIF 0x80 //SPSTAT.7 #define WCOL 0x40 //SPSTAT.6 sfr SPCTL = 0x85; //SPI control register #define SSIG 0x80 //SPCTL.7 #define SPEN 0x40 //SPCTL.6 #define DORD 0x20 //SPCTL.5 #define MSTR 0x10 //SPCTL.4 #define CPOL 0x08 //SPCTL.3 #define CPHA 0x04 //SPCTL.2 #define SPDHH 0x00 //CPU_CLK/4 #define SPDH 0x01 //CPU_CLK/16 #define SPDL 0x02 //CPU_CLK/64 #define SPDLL 0x03 //CPU_CLK/128 sfr SPDAT = 0x86; //SPI data register sbit SPISS = P1^3; //SPI slave select, connect to slave' SS(P1.4) pin void InitUart(); void InitSPI(); void SendUart(BYTE dat); //send data to PC BYTE RecvUart(); //receive data from PC BYTE SPISwap(BYTE dat); //swap SPI data between master 299 |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |