匿名
未登录
登录
丢石头百科
搜索
查看“使用74LS165将AVR的串口输入扩为并口输入”的源代码
来自丢石头百科
名字空间
页面
讨论
更多
更多
页面选项
查看
查看源代码
历史
←
使用74LS165将AVR的串口输入扩为并口输入
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
<table border="0" cellpadding="0" cellspacing="0" style="color: rgb(72, 61, 139); font-family: Arial, 新宋体, 微软雅黑; font-size: 12px;" width="780"><tr><th class="type_483D8B" scope="col" style="line-height: 20px; font-weight: normal; border-top-style: none;" valign="top"><div align="left"><table border="0" cellpadding="0" cellspacing="0" width="120"><tr><th bgcolor="#698192" class="white_12px_b" height="20" scope="col" style="font-size: 12px; color: rgb(255, 255, 255); line-height: 20px; font-family: Arial, Helvetica, sans-serif;">系统功能</th></tr></table><br/> 使用74LS165将AVR的串口输入扩为并口输入。<br/><br/><br/></div></th></tr><tr><th class="type_483D8B" scope="col" style="line-height: 20px; font-weight: normal; border-top-style: none;" valign="top"><div align="left"><table border="0" cellpadding="0" cellspacing="0" width="120"><tr><th bgcolor="#698192" class="white_12px_b" height="20" scope="col" style="font-size: 12px; color: rgb(255, 255, 255); line-height: 20px; font-family: Arial, Helvetica, sans-serif;">硬件设计</th></tr></table> <p align="center">[[File:使用74LS165将AVR的串口输入扩为并口输入-0.jpg|400px]]<br/>AVR主控电路原理图(点击图片放大,不需要放大镜![[File:使用74LS165将AVR的串口输入扩为并口输入-1.gif|400px]])<br/>[[File:使用74LS165将AVR的串口输入扩为并口输入-2.jpg|400px]]<br/>串行输入扩展为并行输入芯片74LS165控制电路原理图(点击图片放大,不需要放大镜![[File:使用74LS165将AVR的串口输入扩为并口输入-1.gif|400px]])<br/><br/></p></div></th></tr><tr><th class="type_483D8B" scope="col" style="line-height: 20px; font-weight: normal; border-top-style: none;" valign="top"><div align="left" class="type_666666_12px" style="color: rgb(102, 102, 102); border-top-style: none; font-family: Arial, Helvetica, sans-serif;"><table border="0" cellpadding="0" cellspacing="0" width="120"><tr><th bgcolor="#698192" class="white_12px_b" height="20" scope="col" style="font-size: 12px; color: rgb(255, 255, 255); line-height: 20px;">软件设计</th></tr></table><br/>下面部分从TXT拷出,拷到网页,代码部分缺省了很多空格,比较凌乱,请谅解!<br/><br/>//目标系统: 基于AVR单片机<br/>//应用软件: ICC AVR<br/><p class="type_666666_12px" style="border-top-style: none;">/*01010101010101010101010101010101010101010101010101010101010101010101<br/>----------------------------------------------------------------------<br/>实验内容:<br/>使用PA口作为信号源输入到74LS165,74LS165将会将该信号转为串行信号,<br/>MCU再自己接收串行信号,使用PB口的LED指示灯查看数据是否正确。<br/>----------------------------------------------------------------------<br/>硬件连接:<br/>将PB口的LED指示灯开关切换到"ON"状态。<br/> SeialBoard(165PrlPort) SMK1632<br/> P0 --------- PB0<br/> P1 --------- PB1<br/> P2 --------- PB2<br/> P3 --------- PB3<br/> P4 --------- PB4<br/> P5 --------- PB5<br/> P6 --------- PB6<br/> P7 --------- PB7<br/> PL --------- PD2<br/> SeialBoard(165SrlPort) SMK1632<br/> VCC --------- VCC<br/> GND --------- GND<br/> TXD --------- RXD<br/> RXD --------- TXD<br/>----------------------------------------------------------------------<br/>注意事项:<br/>(1)若有加载库程序,请将光盘根目录下的“库程序”下的“ICC_H”文件夹拷到D盘<br/>(2)请详细阅读:光盘根目录下的“产品资料\开发板实验板\SMK系列\SMK1632\说明资料”<br/>----------------------------------------------------------------------<br/>10101010101010101010101010101010101010101010101010101010101010101010*/</p><p>#include <iom16v.h><br/>#include "D:\ICC_H\CmmICC.H"</p><p>#define DISP_DDR DDRB<br/>#define DISP_PORT PORTB</p><p>#define SOURCE_DDR DDRA<br/>#define SOURCE_PORT PORTA</p><p>#define IN_RXD cbi(DDRD,0) //PD0 数据口<br/>#define GET_RXD gbi(PIND,0)</p><p>#define OUT_TXD sbi(DDRD,1) //PD1 脉冲口<br/>#define SET_TXD sbi(PORTD,1)<br/>#define CLR_TXD cbi(PORTD,1)</p><p>#define OUT_PL sbi(DDRD,2) //PD2 锁存口<br/>#define SET_PL sbi(PORTD,2)<br/>#define CLR_PL cbi(PORTD,2)</p><p>/*--------------------------------------------------------------------<br/>程序名称:从74LS165获取数据<br/>程序功能:<br/>注意事项:<br/>提示说明:<br/>输 入:<br/>返 回:<br/>--------------------------------------------------------------------*/<br/>uint8 getDat()<br/>{<br/> uint8 i,dat;</p><p> for(i=0;i<8;i++) //循环输出8位数据<br/> {<br/> SET_TXD; //设置为高电平<br/> if(GET_RXD) //下降沿时候获取数据<br/> dat |= 0x01;<br/> dat = dat<<1;<br/> CLR_TXD; //设置为低电平<br/> }<br/> dat = dat>>1;<br/> return dat;<br/>}<br/>/*--------------------------------------------------------------------<br/>程序名称:<br/>程序功能:<br/>注意事项:<br/>提示说明:<br/>输 入:<br/>返 回:<br/>--------------------------------------------------------------------*/<br/>void main()<br/>{ <br/> uint8 i;<br/> <br/> DISP_DDR = 0XFF;<br/> SOURCE_DDR = 0XFF;<br/> OUT_PL;<br/> OUT_TXD;<br/> IN_RXD;<br/> //while(1)<br/> //{<br/> SOURCE_PORT = 0X55;<br/> SET_PL;<br/> CLR_PL;<br/> SET_PL;<br/> DISP_PORT = getDat();<br/> //}<br/>}</p><p></p></div></th></tr><tr><th class="type_483D8B" scope="col" style="line-height: 20px; font-weight: normal; border-top-style: none;" valign="top"><div align="left"><br/><table border="0" cellpadding="0" cellspacing="0" width="120"><tr><th bgcolor="#698192" class="white_12px_b" height="20" scope="col" style="font-size: 12px; color: rgb(255, 255, 255); line-height: 20px; font-family: Arial, Helvetica, sans-serif;">系统调试</th></tr></table><p class="type_666666_12px" style="color: rgb(102, 102, 102); border-top-style: none; font-family: Arial, Helvetica, sans-serif;">将74LS165的输入端口P0--P7接入单片机的PB口,那么PB口输出的数据经过74LS165的转换变为串行数据,将串行数据接入串口,那样若正常工作接收到的数据将与从PB口发出的数据一致,用LED指示串口接收到的数据,进行观察。<br/><br/></p></div></th></tr></table>
返回至
使用74LS165将AVR的串口输入扩为并口输入
。
导航
导航
首页
最近更改
随机页面
MediaWiki帮助
首页
首页
树莓派
主机
配件包
外壳
键鼠
电源
扩展板
显示屏
墨水屏
摄像模块
通信模块
继电器
电机驱动板
游戏机
产品分类
树莓派
Arduino
micro:bit
STM32
Espressif
WiFi模块
蓝牙模块
无线模块
LoRa模块
4G模块
GSM
GPRS
以太网
导航模块
北斗卫星
GPS
LCD
墨水屏
OLED
摄像头
USB模块
串口模块
RS232
RS485
CAN
传感器
温度模块
湿度模块
气压模块
继电器
电机模块
指纹模块
电平转换
音频模块
编程器
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志