第三次实验 串口实验教案资料
合集下载
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include "2440lib.h"
#include "2440slib.h"
#include <string.h>
#include <stdio.h>
//================================
#define rUTRSTAT0(*(volatile unsigned *)0x50000010)
case 'c':
Uart_Printf("\nYou Pressed 'c'");
点流水灯
break;
default :
break;
}
}
return 0;
}
//*************************[ MPLL ]*******************************
void ChangeMPllValue(int mdiv,int pdiv,int sdiv)
Uart_SendByte(aa );
Uart_SendByte(10);
switch(aa)
{
case 'a':
Uart_Printf("\nYou Pressed 'a'");
点流水灯
break;
case 'b':
Uart_Printf("\nYou Pressed 'b'");
点流水灯
brห้องสมุดไป่ตู้ak;
#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);
rGPCCON = 0xaaa956aa;
rGPCUP = 0xffff;
rGPDCON = 0xaaaaaaaa;
rGPDUP = 0xffff;
rGPECON = 0xa02aa800;
rGPEUP = 0xffff;
rGPFCON = 0x55aa;
rGPFUP = 0xff;
rGPGCON = 0x00a2aaaa;
rEXTINT1 = 0x22222222;
rEXTINT2 = 0x22222222;
}
void Uart_Select(int ch)
{
whichUart = ch;
}
逐条注释语句
void Uart_Init(int pclk,int baud)
{
int i;
if(pclk == 0)
pclk = 38000000;
3.串口初始化函数Uart_Init(0,115200),对其记录(截图,截和自己实验相关的串口),并进行注释;计算出波特率;
4.函数Uart_Select(0)是什么?解释清楚;
5.编写接收一个字节的函数aa= Uart_Getch();对其进行详细的记录和解释;
6.完成:如何发送一个字符?
7.画接收过程的流程图。
void Uart_SendString(char *pt);
void Uart_Printf(char *fmt,...);
void dely(U32 tt)
{
U32 i;
for(;tt>0;tt--)
{
for(i=0;i<10000;i++){}
}
}
intMain(int argc, char **argv)
三、实验步骤
1.新建工程文件。
2.定义与UART有关的各个寄存器地址和一些特殊的位命令,加以解释。
3.编写串口驱动函数:
4.在主函数中实现将从串口0接收到的数据发送到串口0(Main.c):
实验参考程序:
#include "def.h"
#include "option.h"
#include "2440addr.h"
{
rMPLLCON = (mdiv<<12) | (pdiv<<4) | sdiv;//计算PCLK的大小?
}
在下面的函数中那条语句完成了对串口用到的端口的初始化?
void Port_Init(void)
{
rGPACON = 0x7fffff;
rGPBCON = 0x015550;
rGPBUP = 0x7ff;
rGPGUP = 0xffff;
rGPHCON = 0x00faaa;
rGPHUP = 0x7ff;
rGPJCON = 0x02aaaaaa;
rGPJUP = 0x1fff;
//External interrupt will be falling edge triggered.
rEXTINT0 = 0x22222222;
for(i=0;i<100;i++);
}
// pclk = PCLK;
rUFCON0 = 0x0;
rUFCON1 = 0x0;
rUFCON2 = 0x0;
rUMCON0 = 0x0;
rUMCON1 = 0x0;
//UART0
rULCON0 = 0x3;
rUCON0 = 0x245;
rUBRDIV0=( (int)(pclk/16./baud+0.5) -1 );
#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)
//UART1
rULCON1 = 0x3;
rUCON1 = 0x245;
rUBRDIV1=( (int)(pclk/16./baud+0.5) -1 );
//UART2
rULCON2 = 0x3;
rUCON2 = 0x245;
rUBRDIV2=( (int)(pclk/16./baud+0.5) -1 );
第三次实验 串口实验
第三次实验串口实验
一、实验报告内容:
1、实验目的和内容;
要求:通过串口0从PC机接收数据,再发给PC机显示出来,再结合流水灯显示。
2、自己编写的程序;
3、实验现象记录和相关截图;
4、实验中出现问题和调试分析。
二、实验任务:
1.看懂原理图的接口连接;
2.端口初始化函数Port_Init(),找到和串口相关的初始化语句,解释;
{
char c1[1];
char err;
U8 aa;
ChangeMPllValue(68,1,1);
Port_Init();
Uart_Select(0);
Uart_Init(0,115200);
MMU_DisableICache();
MMU_DisableDCache();
while(1)
{
aa= Uart_Getch();
#include "2440slib.h"
#include <string.h>
#include <stdio.h>
//================================
#define rUTRSTAT0(*(volatile unsigned *)0x50000010)
case 'c':
Uart_Printf("\nYou Pressed 'c'");
点流水灯
break;
default :
break;
}
}
return 0;
}
//*************************[ MPLL ]*******************************
void ChangeMPllValue(int mdiv,int pdiv,int sdiv)
Uart_SendByte(aa );
Uart_SendByte(10);
switch(aa)
{
case 'a':
Uart_Printf("\nYou Pressed 'a'");
点流水灯
break;
case 'b':
Uart_Printf("\nYou Pressed 'b'");
点流水灯
brห้องสมุดไป่ตู้ak;
#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);
rGPCCON = 0xaaa956aa;
rGPCUP = 0xffff;
rGPDCON = 0xaaaaaaaa;
rGPDUP = 0xffff;
rGPECON = 0xa02aa800;
rGPEUP = 0xffff;
rGPFCON = 0x55aa;
rGPFUP = 0xff;
rGPGCON = 0x00a2aaaa;
rEXTINT1 = 0x22222222;
rEXTINT2 = 0x22222222;
}
void Uart_Select(int ch)
{
whichUart = ch;
}
逐条注释语句
void Uart_Init(int pclk,int baud)
{
int i;
if(pclk == 0)
pclk = 38000000;
3.串口初始化函数Uart_Init(0,115200),对其记录(截图,截和自己实验相关的串口),并进行注释;计算出波特率;
4.函数Uart_Select(0)是什么?解释清楚;
5.编写接收一个字节的函数aa= Uart_Getch();对其进行详细的记录和解释;
6.完成:如何发送一个字符?
7.画接收过程的流程图。
void Uart_SendString(char *pt);
void Uart_Printf(char *fmt,...);
void dely(U32 tt)
{
U32 i;
for(;tt>0;tt--)
{
for(i=0;i<10000;i++){}
}
}
intMain(int argc, char **argv)
三、实验步骤
1.新建工程文件。
2.定义与UART有关的各个寄存器地址和一些特殊的位命令,加以解释。
3.编写串口驱动函数:
4.在主函数中实现将从串口0接收到的数据发送到串口0(Main.c):
实验参考程序:
#include "def.h"
#include "option.h"
#include "2440addr.h"
{
rMPLLCON = (mdiv<<12) | (pdiv<<4) | sdiv;//计算PCLK的大小?
}
在下面的函数中那条语句完成了对串口用到的端口的初始化?
void Port_Init(void)
{
rGPACON = 0x7fffff;
rGPBCON = 0x015550;
rGPBUP = 0x7ff;
rGPGUP = 0xffff;
rGPHCON = 0x00faaa;
rGPHUP = 0x7ff;
rGPJCON = 0x02aaaaaa;
rGPJUP = 0x1fff;
//External interrupt will be falling edge triggered.
rEXTINT0 = 0x22222222;
for(i=0;i<100;i++);
}
// pclk = PCLK;
rUFCON0 = 0x0;
rUFCON1 = 0x0;
rUFCON2 = 0x0;
rUMCON0 = 0x0;
rUMCON1 = 0x0;
//UART0
rULCON0 = 0x3;
rUCON0 = 0x245;
rUBRDIV0=( (int)(pclk/16./baud+0.5) -1 );
#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)
//UART1
rULCON1 = 0x3;
rUCON1 = 0x245;
rUBRDIV1=( (int)(pclk/16./baud+0.5) -1 );
//UART2
rULCON2 = 0x3;
rUCON2 = 0x245;
rUBRDIV2=( (int)(pclk/16./baud+0.5) -1 );
第三次实验 串口实验
第三次实验串口实验
一、实验报告内容:
1、实验目的和内容;
要求:通过串口0从PC机接收数据,再发给PC机显示出来,再结合流水灯显示。
2、自己编写的程序;
3、实验现象记录和相关截图;
4、实验中出现问题和调试分析。
二、实验任务:
1.看懂原理图的接口连接;
2.端口初始化函数Port_Init(),找到和串口相关的初始化语句,解释;
{
char c1[1];
char err;
U8 aa;
ChangeMPllValue(68,1,1);
Port_Init();
Uart_Select(0);
Uart_Init(0,115200);
MMU_DisableICache();
MMU_DisableDCache();
while(1)
{
aa= Uart_Getch();