c8051f023串口发送数据实验在keil v4下仿真成功,但下载到目....

2020-02-05 08:56发布

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);
    }

}

TESTCOM.JPG (362.1 KB, 下载次数: 0) 下载附件 2012-6-23 23:01 上传
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
7条回答
dengxm2009
1楼-- · 2020-02-05 13:06
自己顶顶!!!高手快来呀!
dengxm2009
2楼-- · 2020-02-05 16:08
再顶一下!!!!
jetli
3楼-- · 2020-02-05 21:15
dengxm2009
4楼-- · 2020-02-06 00:10
再顶一下!!!!
llssr
5楼-- · 2020-02-06 02:03
 精彩回答 2  元偷偷看……
视觉℡
6楼-- · 2020-02-06 02:51
留名备用!!!

一周热门 更多>