|
c8051f023串口发送数据实验在keil v4下仿真成功,但下载到目标板中串口无输出,大虾看看!
/////////////////////////////////////
// Generated Initialization File //
/////////////////////////////////////
#include "C8051F020.h"
#include "string.h"
// Peripheral specific initialization functions,
// Called from the Init_Device() function
sbit PowerOn=P1^4;
void Reset_Sources_Init()
{
WDTCN = 0xDE;
WDTCN = 0xAD;
}
void Timer_Init()
{
CKCON = 0x10;
TCON = 0x40;
TMOD = 0x20;
TH1 = 0xC4;
}
void UART_Init()
{
SCON0 = 0x40;
}
void Port_IO_Init()
{
P0MDOUT = 0x03;
P1MDOUT = 0x10;
XBR0 = 0x04;
XBR2 = 0x40;
}
void Oscillator_Init()
{
int i = 0;
OSCXCN = 0x67;
for (i = 0; i < 3000; i++); // Wait 1ms for initialization
while ((OSCXCN & 0x80) == 0);
OSCICN = 0x0E;
}
void Interrupts_Init()
{
//IE = 0x10;
}
// Initialization function for device,
// Call Init_Device() from your main program
void Init_Device(void)
{
Reset_Sources_Init();
Timer_Init();
UART_Init();
Port_IO_Init();
Oscillator_Init();
Interrupts_Init();
}
void delayms(int dlt)
{
int i,j;
for (i=0; i<=dlt; i++)
{
for (j=0; j<=3000; j++)
{
}
}
}
void SendStringToCom0(char *TestStr,int StrLen)
{
int i;
char ts='1';
char *p;
p=TestStr;
for (i=0; i<=StrLen; i++)
{
ts= p[0];
SBUF0 = ts ; //送入缓冲区
while(TI0 == 0); //等待发送完毕
TI0 = 0; //软件清零
p++;
}
}
void main()
{
char *TestStr="Uart0 Port Test is running!";
int InfoLen=strlen(TestStr);
Init_Device();
PowerOn=1;
delayms(1000);
while (1)
{
SendStringToCom0(TestStr,InfoLen);
delayms(3000);
}
}
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|