第三次实验串口实验
一、实验报告内容:
1、实验目的和内容;
要求:通过串口0从PC机接收数据,再发给PC机显示出来,再结合流水灯显示。
2、自己编写的程序;
3、实验现象记录和相关截图;
4、实验中出现问题和调试分析。
二、实验任务:
看懂原理图的接口连接;
端口初始化函数Port_Init(),找到和串口相关的初始化语句,解释;
串口初始化函数Uart_Init(0,115200),对其记录(截图,截和自己实验相关的串口),并进行注释;计算出波特率;
函数Uart_Select(0)是什么?解释清楚;
编写接收一个字节的函数aa= Uart_Getch();对其进行详细的记录和解释;
完成:如何发送一个字符?
画接收过程的流程图。
三、实验步骤
。
有关的各个寄存器地址和一些特殊的位命令,加以解释。
:
接收到的数据发送到串口0():
实验参考程序:
#include ""
#include ""
#include ""
#include ""
#include ""
#include <>
#include <>
//================================
#define rUTRSTAT0 (*(volatile unsigned *)0x50000010)
#define rUTRSTAT1 (*(volatile unsigned *)0x50004010)
#define WrUTXH0(ch) (*(volatile unsigned char *)0x50000020)=(unsigned char)(ch)
#define WrUTXH1(ch) (*(volatile unsigned char *)0x50004020)=(unsigned char)(ch)
#define RdURXH0() (*(volatile unsigned char *)0x50000024)
#define RdURXH1() (*(volatile unsigned char *)0x50004024)
void Uart_Init(int mclk,int baud);
void Uart_Select(int ch);
void Uart_TxEmpty(int ch);
char Uart_Getch(void);
char Uart_GetKey(void);
void Uart_GetString(char *string);
int Uart_GetIntNum(void);
void Uart_SendByte(int data);
void Uart_SendString(char *pt);
void Uart_Printf(char *fmt,...);
void dely(U32 tt)
{
U32 i;
for(;tt>0;tt--)
{
for(i=0;i<1000
第三次实验 串口实验 来自淘豆网m.daumloan.com转载请标明出处.