导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→有用过MSC1211的吗?帮忙啊,[andyer88]

 *第47382篇: 有用过MSC1211的吗?帮忙啊,

  
楼 主:andyer88 2007年3月29日16:18
 有用过MSC1211的吗?帮忙啊,
有用过MSC1211的吗?我在做一个串口接收终端的程序,非常奇怪,总是经常不知道加了那句话或者怎么样就不进中断了,
  
2楼:andyer88 2007年3月29日16:32
 我的程序是这样的
#include   <REG1211.h>  
#include   <stdio.h>  
#include   <stdlib.h>  
#include   <math.h>  
#include   <string.h>  


#define INBUF_LEN 50   //数据长度

unsigned char receiveCount = 0; //已接收字符数
unsigned char receiveData;

unsigned char inbuf1[INBUF_LEN];


void init_serialcomm(void)
{   
    IE=0;
    TMOD |= 0x20;     //TMOD: timer 1, mode 2, 8-bit reload 

    TH1 = 0xFA;       //Baud:9600  fosc=11.0592MHz 
    TL1 = 0xFA; 
 
 TCON |= 0x40;  // Enable Timer 1
    EICON |= 0x80;    //SMOD1=1;     
 SCON1 = 0x50;     //SCON: serail mode 1, 8-bit UART, enable ucvr 
 


}


//向串口发送一个字符 

void send_char_com(unsigned char c)  
{
    SBUF1=c;
    while(TI_1==0);
    TI_1=0;
}

void serial () interrupt 15 using 0
{  
     
    if(RI_1)
    {   
  
  RI_1 = 0;
  T0 = ~T0; //发光二极管交替闪烁
     inbuf1[receiveCount] = SBUF1;
        send_char_com( receiveCount+'0' );
        receiveCount++;
  
    }
}


void main()
{   
    int i = 0;
    init_serialcomm();
 receiveCount = 0;
 EA=1; 
 ES1=1;       //Enable Serial Interrupt


 
}
程序是这样的,应该随着发送数的增加,接收到的应该是0123...但是收到的全是零

  
3楼:jachen02 2007年3月29日18:49
 接口狀態沒定好
接口狀態沒定好
  
4楼:andyer88 2007年4月3日10:50
 [讨论]
您能具体说明一下么??感谢

>>>>>>对该主题发表你的看法

本主题贴数4,分页: [第1页]


[上一篇主题]:贺新春,送大礼,亚嵌嵌入式linux课程6.8折优惠

[下一篇主题]:电路设计问题,盼回复交流: