所有资料打包下载:
74LS165测试版本.zip
(87.81 KB, 下载次数: 52)
小弟在网上苦寻级联程序都不得,好不容易找到了,结果测试不能用,于是自己做了个,希望各位下载后,能够继续将自己的上传,大家共同进步,以下程序和仿真都是我亲自完成,如有不解可联系本人,412489601@qq.com 不吝赐教*/
下面是proteus仿真原理图:
单片机c语言源程序:
- /****************************************Copyright (c)**************************************************
- **
- ** -----------------------------------------------------------------------------------------------------
- ** File Name : 74LS165.C
- ** Version : V1.0.0
- ** Description :
- * 【外部晶振】: 11.0592mhz
- * 【主控芯片】: STC89C52
- * 【编译环境】: Keil μVisio4
- * 【程序功能】:
- * 【使用说明】:
- ** -----------------------------------------------------------------------------------------------------
- ** Author : Creavalia
- ** Date : 2015年10月19日
- ** -----------------------------------------------------------------------------------------------------
- ** Modify Person:
- ** Modify Date :
- ** Description :
- *********************************************************************************************************/
- // Includes --------------------------------------------------------------------------------------------
- #include<reg51.h>
- #include<intrins.h>
- /********************************************************************************************************
- ** Marcos define
- *********************************************************************************************************/
- #define uint unsigned int
- #define uchar unsigned char
- //IO设置
- sbit QH = P3^0; //输出端
- sbit CLK = P3^1; //时钟输入端(上升沿有效)
- sbit SPL = P3^2; //移位控制/置入控制(低电平有效)
- /********************************************************************************************************
- * Function Name : read_int165
- * Description : 接收数据
- * Input : None
- * Output : None
- * Return : None
- ********************************************************************************************************/
- uint read_int165(void)
- {
- uchar i = 0;
- uint read_data = 0;
- SPL = 0; //置数,读入并行输入口数据
- _nop_();
- SPL = 1; //移位,并口输入被封锁,串行转换开始
- _nop_();
- for(i=0;i<16;i++) //16位数据
- {
- read_data <<= 1;
- if(QH)
- {
- read_data|=QH;
- }
- CLK=0; //下降沿
- _nop_();
- CLK=1; //上升沿
- _nop_();
- }
- return read_data;
- }
- /********************************************************************************************************
- * Function Name : main
- * Description : 主函数
- * Input : None
- * Output : None
- * Return : None
- ********************************************************************************************************/
- void main()
- {
- //初始化
- uint temp = 0;
- uchar tempH = 0;
- uchar tempL = 0;
- CLK=0;
- while(1)
- {
- temp = read_int165();
- //获取高8位,存放置tempH
- tempH = (uchar) (temp>>8);
- //获取低8位,存放置tempL
- tempL = (uchar) temp;
- P0=tempH; //接收到的字节显示在P0 端口,显示的值与拨码开关对应
- P1=tempL; //接收到的字节显示在P1 端口,显示的值与拨码开关对应
- }
- }
- /*********************************************************************************************************
- ** End Of File
- ********************************************************************************************************/
复制代码 |