标题: 求助,中颖SH79F6486串口中断一直进不去 [打印本页]

作者: lin5422510    时间: 2017-11-16 16:16
标题: 求助,中颖SH79F6486串口中断一直进不去

#include "SH79F6486.H"
#include "SH79F6486E.H"

#include "intrins.h"
#include "ABSACC.H"
#include "stdlib.h"
#define RS485_DIR P1_0
uint8_t receiveData;
void        InitSys(void);
void Init_Clk();

void        main(void)
{
  EA =0;
Init_Clk();
        InitSys();                                        /* 初始化 */
        while(1)
        {
       
        }
}
void Init_Clk()
{ unsigned int Delay;
  OSCLO=0x55;
  CLKCON1 =0x80;//打开12MHz振荡器
  _nop_();
  _nop_();
        //while((CLKCON1 &(1<<6))==0);
        Delay=0xff;
        while(Delay--);
        OSCLO=0x55;
        CLKCON =0x00;
        _nop_();
  _nop_();
        _nop_();
  _nop_();
  OSCLO=0x00;
}
void        InitSys(void)
{
        /*-----------------未使用到的IO口-----------------*/

P2CR=0xFF;
P2PCR=0x00;
P2=0x00;
P2CON=0x00;

P3CR=0xFF;
P3PCR=0x00;
P3=0x00;

P4CR=0xFF;
P4PCR=0x00;
P4=0x00;

P6CR=0xFF;
P6PCR=0x00;
P6=0x00;

P7CR=0xFF;
P7PCR=0x00;
P7=0x00;

P8CR=0xFF;
P8PCR=0x00;
P8=0x00;

P9CR=0xFF;
P9PCR=0x00;
P9=0x00;

P10CR=0xFF;
P10PCR=0x00;
P10=0x00;
P10CON=0x00;

        /*------------------使用到的IO口------------------*/
        P0CR         =0xFB;                                /* P0.2共用作RXD  P0.3共用作TXD */
        P0PCR        = 0x04;
        P0OS=0xff;
        P0= 0x00;
        P1CR=0xFF;
  P1PCR=0x00;
  P1=0x00;

        /*------------------EUART初始化-------------------*/
  PCON        =        0x00;                                /* 设置EUART0的工作方式SM0 SM1 SM2来选择 */
        SCON2        =        0x50;                                /* 设置EUART0为工作模式3,清除发送冲突标志,清除发送中断标志和接收中断标志,允许接收 */               
  SBRTH2=0x7f;/* 设置波特率发生器的溢出值  波特率9600 */
  SBRTL2=0xb2;
  SFINE2=0x02;
        SBRTH2        |=        0x80;                                /* 使能波特率发生器 */
        /*---------------开启EUART2中断---------------*/
        EA=1;                                                                                /*                          Bit7        Bit6  Bit5  Bit4  Bit3  Bit2  Bit1  Bit0 */
        IEN1        =        0x10;                /* IEN1                   ELPD   ES3  EPWM  ES2   EHSEC EX3   EX2   N/A  */
        RS485_DIR =0;
       
}
void delay(uint16_t i)
{
        while(i--);       
}

void InterruptUART() interrupt 11
{  
  receiveData=SBUF2;//出去接收到的数据
        SCON2&=~0x01;//清零接收中断标志位RI2=0
        delay(100);
        RS485_DIR=1;

        SBUF2=receiveData;//将接收到的数据放入到发送寄存器
        while(!(SCON2&0x02));                         //等待发送数据完成
  SCON2&=~0x02;//清零发送中断标志位TI2=0
        RS485_DIR=0;
  
}

作者: 有光    时间: 2020-10-26 14:09
亲,能把SH79F6486这个程序源码发给我吗?




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1