71SPI协议示例

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

SPI8SPISPICCCEEPROMSPISPISPIC8051F30XSPIIOSPIMOSI/C8051F30XMISO/SCKC8051F30XIOIO1SPIC8051F30XSPIC8051F300,C8051F301,C8051F302C8051F303CYGNALIntegratedProducts,Inc.4301WestbankDriveSuiteB-100Austin,TX78746©2001CygnalIntegratedProducts,Inc.1.8SPISPI1234C1CSPIMOSIMSBMISOSCKSPI0CSPI_MODE0.c0SPI_MODE0.asm1CSPI_MODE1.c1SPI_MODE1.asm2CSPI_MODE2.c2SPI_MODE2.asm3CSPI_MODE3.c3SPI_MODE3.asmSPISPIC8051F30XSPISPI2C3034122SPI2AN028-1.0DEC01.2001CygnalIntegratedProducts,Inc.AN028-C8051F30XSPIAN028-1.0DEC01©CygnalIntegratedProducts,Inc.32./MSBMISO/MOSINSSSCKMODE3Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0LSBSCKMODE2SCKMODE1SCKMODE03.03MISOSCKMOSIt1t2t3t4t54.12MISOSCKMOSIt6t7t8t5t4AN028-1.0DEC01.2001CygnalIntegratedProducts,Inc.T1T2T3T4T5T6T7T8-MOSISCKMOSISCKMISOSCKMOSIMOSISCKSCKMOSISCKMOSISCKMISOSCKMOSIMOSISPI03030301230123121212C6622741311810810131166224718222235277555577223225113CSPIC8051F30XIOSPI_Transfer()CexterncharSPI_Transfer(char);externin_spi=SPI_Transfer(out_spi);in_spiout_spiSPI2.SPI5AN028-1.0DEC01.2001CygnalIntegratedProducts,Inc.CSPISPI_F300_Test.cSPISPI_EE_F30x.c03EEPROMSPISPI_F300_Test.cSPI_F300_Test.cfor0-255fortest_counterSPI_returnSPINSSNSSSPISPIUARTPCSPI_F300_Test.c,SPI_defs.hSPI_defs.hSPIsbitSPI_Transfer()SPI_F300_Test.cC8051F30XFLASHMISOMOSIPC115,20081RS-232UARTPCMOSIMISOSPIOut=0xFC,SPIIn=0xFCSPIOut=0xFD,SPIIn=0xFDSPIOut=0xFE,SPIIn=0xFESPIOut=0xFF,SPIIn=0xFFSPIOut=0x00,SPIIn=0x00SPIOut=0x01,SPIIn=0x01SPIOut=0x02,SPIIn=0x02SPIOut=0x03,SPIIn=0x03SPIOut=0x04,SPIIn=0x04SPIOut=0x05,SPIIn=0x05MOSIMISOSPIMOSIMISO6AN028-1.0DEC01101.2001CygnalIntegratedProducts,Inc.SPI_EE_F30x.cSPI_EE_F30x.cSPISPIEEPROMMicrochip25LC320EEPROMSPIO3SPIFLASHEEPROMEEPROMP0.6EEPROMPC115,20081RS-232UART5C8051F30xEEPROM5.EEPROMAN028-C8051F30XSPIAN028-1.0DEC01©CygnalIntegratedProducts,Inc.7//-----------------------------------------------------------------------------//SPI_defs.h//-----------------------------------------------------------------------------//Copyright2001CygnalIntegratedProducts,Inc.////:BD//:2001127////SPI//SPIP0.0-P0.3,//GPIO//#ifndefSPI_DEFS#defineSPI_DEFSsbitMOSI=P0^0;///()sbitMISO=P0^1;///()sbitSCK=P0^2;//()sbitNSS=P0^3;//()#endifAN028-C8051F30XSPIAN028-1.0DEC01©CygnalIntegratedProducts,Inc.8//-----------------------------------------------------------------------------//SPI_MODE0.c//-----------------------------------------------------------------------------//Copyright2001CygnalIntegratedProducts,Inc.////BD//20011214////0SPIC////t:C8051F30x//KEILC516.03/KEILEVALC51////#includec8051f300.h//SFR#includeSPI_defs.h//SPI//-----------------------------------------------------------------------------//SPI_Transfer//-----------------------------------------------------------------------------////SPISPI_byte//SCKSCK//////////MOSISCK6//SCKMISO2//SCKMOSI7//SCK8//SCK13charSPI_Transfer(charSPI_byte){unsignedcharSPI_count;//SPIfor(SPI_count=8;SPI_count0;SPI_count--)//SPI{MOSI=SPI_byte&0x80;//MOSISPI_byte=SPI_byte1;//MSBSCK=0x01;//SCKSPI_byte|=MISO;//MISOSCK=0x00;//}return(SPI_byte);AN028-C8051F30XSPIAN028-1.0DEC01©CygnalIntegratedProducts,Inc.9}//SPI_Transfer;-----------------------------------------------------------------------------;Copyright(C)2001CYGNALINTEGRATEDPRODUCTS,INC.;Allrightsreserved.;;SPI_MODE0.ASM;20011214;MCU:C8051F30x;C8051F30XSPI;C;;;;externcharSPI_Transfer(char);;;0SPI;;MOSISCK2;SCKMISO2;SCKMOSI5;SCK5;SCK7;;-----------------------------------------------------------------------------NAMESPI_MODE0?PR?_SPI_Transfer?SPI_MODE0SEGMENTCODEPUBLIC_SPI_Transfer$include(c8051f300.inc);$include(SPI_defs.h);SPIRSEG?PR?_SPI_Transfer?SPI_MODE0_SPI_Transfer:USING0MOVA,R7;AMOVR7,#08H;R7RLCA;MSBSPI_Loop:MOVMOSI,C;MOSISETBSCK;MOVC,MISO;MISORLCA;ACLRSCK;DJNZR7,SPI_Loop;MOVR7,A;R7?C0001:AN028-C8051F30XSPIAN028-1.0DEC01©CygnalIntegratedProducts,Inc.10RET;END;//-----------------------------------------------------------------------------//SPI_MODE1.c//-----------------------------------------------------------------------------//Copyright2001CygnalIntegratedProducts,Inc.////BD//20011214////1SPIC////t:C8051F30x//KEILC516.03/KEILEVALC51////#includec8051f300.h//SFR#includeSPI_defs.h//SPI//-----------------------------------------------------------------------------//SPI_Transfer//-----------------------------------------------------------------------------////SPISPI_byte//SCKSCK//////////SCKMOSI4//MOSISCK6//SCKMISO2//SCK10//SCK11charSPI_Transfer(charSPI_byte){unsignedcharSPI_count;//counterforSPItransactionfor(SPI_count=8;SPI_count0;SPI_count--)//SPI{SCK=0x01;//SCKMOSI=SPI_byte&0x80;//MOSISPI_byte=SPI_byte1;//MSBSCK=0x00;//SCKAN028-C8051F30XSPIAN028-1.0DEC01©CygnalIntegratedProducts,Inc.11SPI_byte|=MISO;//MISO}return(SPI_byte);}//SPI_Transfer;-----------------------------------------------------------------------------;Copyright(C)2001CYGNALINTEGRATEDPRODUCTS,INC.;Allrightsreserved.;;SPI_MODE1.ASM;14DEC01;MCU:C8051F30x;C8051F30XSPI;C;;;externcharSPI_Transfer(char);;;1SPI);;SCKMOSI2;MOSISCK2;SCKMISO3;SCK5;S

1 / 28
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功