在主函数中定义一个变量或是其他函数中定义的变量,在调试时查看变量的值,从而确定程序是否正常运行。
但是在使用N79E814A单片机时,使用printf函数打印字符串可以,但是打印对应的变量值不正确。
例如:printf("\n x is %d",x);这样使用打印出的数值完全不是对应的数值。
有谁碰到过,有大神吗???求解释啊!!!以前使用51单片机都是这么调试的啊
UINT8 u8Uart_Data;
UINT8 x=0;
extern UINT8 y;
UINT8 z=1;
//-----------------------------------------------------------------------------------------------------------
void main (void)
{
AUXR1 |= Uart_Port_Sel; // Select P10/P11 as UART pin(default)
InitialUART0_Timer1(9600); // 9600 Baud Rate @ 11.0592MHz
Show_Version_Number_To_PC();
printf ("\n*===================================================================");
printf ("\n* Name: N79E84x Series UART Sample Code.");
printf ("\n*===================================================================");
printf ("\n UART receive a byte and transmit the same byte to PC.\n");
// printf ("\n FOSC_110592=%f\n",FOSC_110592);
printf ("\n x=%d\n",x);
printf ("\n y=%d\n",y);
printf ("\n z=%d\n",z);
// printf ("\n FOSC_221184=%f\n",FOSC_221184);
ES = 1; // Enable serial interrupt
EA = 1; // Enable global interrupt
while(1); // Endless
}
//-----------------------------------------------------------------------------------------------------------
void UART_ISR(void) interrupt 4
{
if (RI == 1)
{ // If reception occur
RI = 1; // Clear reception flag for next reception
u8Uart_Data = SBUF; // Read receive data
SBUF = u8Uart_Data; // Send back same data on UART
}
else TI = 0; // If emission occur
// Clear emission flag for next emission
}
打印的结果却是
====================================================================
* Copyright(c) 2014 Nuvoton Technology Corp. All rights reserved.
* Sample Name : Nuvoton N79E81x Series Sample Code.
* Contact E-Mail: MicroC-8bit@nuvoton.com
* Sample Version : 1. 0. 2
* Finished Date : 2014. 1.23
====================================================================
*===================================================================
* Name: N79E84x Series UART Sample Code.
*===================================================================
UART receive a byte and transmit the same byte to PC.
void UART_ISR(void) interrupt 4
{
if (RI == 1)
{ // If reception occur
RI = 1; // Clear reception flag for next reception
u8Uart_Data = SBUF; // Read receive data
SBUF = u8Uart_Data; // Send back same data on UART
}
else TI = 0; // If emission occur
// Clear emission flag for next emission
}