74hc165串口转并口输入

74hc165.h

#ifndef _74H165_H_
#define _74H165_H_


#include<reg51.h>
#include<intrins.h>
#define GPIO_LED P0
sbit IN_PL = P1^6;
sbit IN_Data = P1^7;
sbit SCK = P3^6;
#ifndef uchar 
#define uchar unsigned char
#endif
#ifndef uint 
#define uint unsigned int
#endif
uchar read74H165();

#endif

74hc165.c

#include<74H165.h>


uchar read74H165()
{
    uchar i;
    uchar indata;

    //将数据并行输入
    IN_PL = 0;       
    _nop_();
    IN_PL = 1;
    _nop_();

    indata = 0;     //保存的数据清零
    for(i = 0; i < 8; i++)
    {
        indata = indata << 1;
        SCK = 0;
        _nop_();
        indata |= IN_Data;
        SCK = 1;
    }

    return indata;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值