关于mini2440与pc 串口通信的问题

qqqincheng 2011-03-30 07:21:40
//====================================================================
// File Name : Adc.c
// Function : S3C2410 ADC Test
// Program : Kang, Weon Tark
// Date : May 22, 2002
// Version : 0.0
// History
// 0.0 : Programming start (March 29,2002) -> KWT
// ADC Test -> May 15, 2002 SOP
//====================================================================

#include <stdlib.h>
#include <string.h>
#include "2440addr.h"
#include "2440lib.h"
#include "2440slib.h"
#include "def.h"
#include "option.h"
#include "mmu.h"
#include "profile.h"
#include "memtest.h"

#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>




//***************************[ UART ]******************************
static int whichUart=0;

void Uart_Init(int pclk,int baud)
{
int i;
if(pclk == 0)
pclk = PCLK;
rUFCON0 = 0x0; //UART channel 0 FIFO control register, FIFO disable
rUFCON1 = 0x0; //UART channel 1 FIFO control register, FIFO disable
rUFCON2 = 0x0; //UART channel 2 FIFO control register, FIFO disable
rUMCON0 = 0x0; //UART chaneel 0 MODEM control register, AFC disable
rUMCON1 = 0x0; //UART chaneel 1 MODEM control register, AFC disable
//UART0
rULCON0 = 0x3; //Line control register : Normal,No parity,1 stop,8 bits
// [10] [9] [8] [7] [6] [5] [4] [3:2] [1:0]
// Clock Sel, Tx Int, Rx Int, Rx Time Out, Rx err, Loop-back, Send break, Transmit Mode, Receive Mode
// 0 1 0 , 0 1 0 0 , 01 01
// PCLK Level Pulse Disable Generate Normal Normal Interrupt or Polling
rUCON0 = 0x245; // Control register
rUBRDIV0=( (int)(pclk/16./baud+0.5) -1 ); //Baud rate divisior register 0
//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 );

for(i=0;i<100;i++);
}

//===================================================================
void Uart_Select(int ch)
{
whichUart = ch;
}

//===================================================================
void Uart_TxEmpty(int ch)
{
if(ch==0)
while(!(rUTRSTAT0 & 0x4)); //Wait until tx shifter is empty.

else if(ch==1)
while(!(rUTRSTAT1 & 0x4)); //Wait until tx shifter is empty.

else if(ch==2)
while(!(rUTRSTAT2 & 0x4)); //Wait until tx shifter is empty.
}

//=====================================================================
void Uart_SendByte(int data)
{
if(whichUart==0)
{
if(data=='\n')
{
while(!(rUTRSTAT0 & 0x2));
// Delay(1); //because the slow response of hyper_terminal
WrUTXH0('\r');
}
while(!(rUTRSTAT0 & 0x2)); //Wait until THR is empty.
// Delay(1);
WrUTXH0(data);
}
else if(whichUart==1)
{
if(data=='\n')
{
while(!(rUTRSTAT1 & 0x2));
//Delay(1); //because the slow response of hyper_terminal
rUTXH1 = '\r';
}
while(!(rUTRSTAT1 & 0x2)); //Wait until THR is empty.
//Delay(1);
rUTXH1 = data;
}
else if(whichUart==2)
{
if(data=='\n')
{
while(!(rUTRSTAT2 & 0x2));
//Delay(1); //because the slow response of hyper_terminal
rUTXH2 = '\r';
}
while(!(rUTRSTAT2 & 0x2)); //Wait until THR is empty.
//Delay(1);
rUTXH2 = data;
}
}




void Main(void)
{
//#########################################################################
int i;
U8 key;
U32 mpll_val=0;
key = 14;
mpll_val = (92<<12)|(1<<4)|(1);
Port_Init();
ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);
ChangeClockDivider(key, 12);
MMU_DisableICache();
MMU_DisableDCache();
//rGPBCON = 0x155555;
Uart_Init( 0,115200 );
Uart_Select( 0 );

//##########################################################################


while(1)
{
//rGPBDAT =0x7fe;
Delay(1000) ;
//rGPBDAT =0x001;
Delay(1000) ;
Uart_SendByte('g');
//Uart_Printf("SBC2440 Test Program VER1.0\n");
}
//Uart_Init( 0,115200 );
//Uart_Select( 0 );
//Uart_Printf("SBC2440 Test Program VER1.0\n");
}



以上是 我在文档上面扣出来的程序 但是 就是不能在终端上面打印字符
希望各位多多帮忙
...全文
339 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Chris_xi 2011-03-31
  • 打赏
  • 举报
回复
不知道你按具体什么情况;
1.看下线连得OK不
2.看下COM口,波特率设置对了没
dceacho 2011-03-30
  • 打赏
  • 举报
回复
我只有CE下的串口程序,自己用了下还不错

27,382

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 单片机/工控
社区管理员
  • 单片机/工控社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧