求大侠搭救:我用N76E885双串口,在keil中进debug都到不了run to main, 关掉任意一个串口就可以debug run to main
#define SYS_CLK_EN 1
#define SYS_SEL 2
#define SYS_DIV_EN 0 //0: Fsys=Fosc, 1: Fsys = Fosc/(2*CKDIV)
#define SYS_DIV 1
#define PRE_SCALAR 7
#define WDT_MODE 0
bit BIT_TMP;
UINT8 UART0_RX_FLAG;
UINT8 UART0_RX_BYTE;
UINT8 UART1_RX_FLAG;
UINT8 UART1_RX_BYTE;
/*******************************************************************************
* FUNCTION_PURPOSE: Main function
******************************************************************************/
void main (void)
{
/* Note
MCU power on system clock is HIRC (22.1184MHz), so Fsys = 22.1184MHz
*/
Set_All_GPIO_Quasi_Mode(); //Set all GPIO are Quasi Mode
UART0_RX_FLAG = 0;
UART0_RX_BYTE = 0;
UART1_RX_FLAG = 0;
UART1_RX_BYTE = 0;
InitialUART0_Timer1_Type1(9600); //UART0 Baudrate initial,T1M=0,SMOD=0
InitialUART1_Timer3(9600); /* 9600 Baud Rate*/
/* Change system closk source */
#if SYS_CLK_EN == 1
#if SYS_SEL == 0
System_Clock_Select(E_HXTEN); //Fosc = 2~25MHz XTAL
#elif SYS_SEL == 1
System_Clock_Select(E_LXTEN); //Fosc = 32.768KHz XTAL
#elif SYS_SEL == 2
System_Clock_Select(E_HIRCEN); //Fosc = 22.1184MHz Internal RC
#elif SYS_SEL == 3
System_Clock_Select(E_LIRCEN); //Fosc = 10KHz Internal RC
#elif SYS_SEL == 4
System_Clock_Select(E_OSCEN); //Fosc = OSC-In External OSC
#endif
#endif
#if SYS_DIV_EN == 1
CKDIV = SYS_DIV; //Fsys = Fosc / (2* CLKDIV) = Fcpu
#endif
TA = 0x0AA;
TA = 0x055;
#if PRE_SCALAR == 0
WDCON = 0x00;
#elif PRE_SCALAR == 1
WDCON = 0x01;
#elif PRE_SCALAR == 2
WDCON = 0x02;
#elif PRE_SCALAR == 3
WDCON = 0x03;
#elif PRE_SCALAR == 4
WDCON = 0x04;
#elif PRE_SCALAR == 5
WDCON = 0x05;
#elif PRE_SCALAR == 6
WDCON = 0x06;
#elif PRE_SCALAR == 7
WDCON = 0x07;
#endif
while(1)
{
set_WDTEN; //WDT run
if( UART0_RX_FLAG )
{
UART0_RX_FLAG = 0;
Send_Data_To_UART0( UART0_RX_BYTE );
}
if( UART1_RX_FLAG )
{
UART1_RX_FLAG = 0;
Send_Data_To_UART1( UART1_RX_BYTE );
}
}
}
/******************************************************************************
* FUNCTION_PURPOSE: Serial interrupt, echo received data.
* FUNCTION_INPUTS : P2.0(RXD) serial input
* FUNCTION_OUTPUTS: P0.3(TXD) serial output
******************************************************************************/
void Serial0_ISR (void) interrupt 4
{
if (RI == 1)
{
UART0_RX_FLAG = 1;
UART0_RX_BYTE = SBUF;
clr_RI; // Clear RI (Receive Interrupt).
}
if (TI == 1)
{
clr_TI; // Clear TI (Transmit Interrupt).
}
}
/***************************************************************************************
* FUNCTION_PURPOSE: serial-1 interrupt, echo received data.
* FUNCTION_INPUTS: P2.4(TXD) serial-1 input
* FUNCTION_OUTPUTS: P2.5(RXD) serial-1 output
**************************************************************************************/
void Serial_1_ISR(void) interrupt 15
{
if (RI_1 == 1)
{
// UART1_RX_FLAG = 1;
// UART1_RX_BYTE = SBUF_1;
clr_RI_1; // Clear RI (Receive Interrupt).
}
if (TI_1 == 1)
{
clr_TI_1; // Clear TI (Transmit Interrupt).
}
}
|