Em dùng MikroC viết đoạn code test sau xuất UART, khi compile thì nó báo lỗi Reentrancy is not allowed: function 'UART1_Write' called from two threads __Lib_UART_c67.c, muốn khắc phục thì phải xóa hàm UART1_Write_Text("TEST HARDWARE UART"); khỏi main thì nó mới chạy. Ai gặp lỗi này chỉ dùm em cách khắc phục với ah
Code:
/*******************************************************************************
** Function name: main ()
** Description : main program
******************************************************************************/
int main(void)
{
/* Init System */
Port_Init();
HardwareUart_Config();
UART1_Write_Text("TEST HARDWARE UART");
while (1)
{
}
}
/*******************************************************************************
** Function name: Interrupt (void)
** Description : None
******************************************************************************/
void Interrupt (void)
{
unsigned char HardUART_Rx = 0;
/* UART Rx INTERRUPT ----------------------------------------------
*
*/
if(RCIE_bit && RCIF_bit)
{
RCIF_bit = 0;
if(UART1_Data_Ready())
{
HardUART_Rx = UART1_Read();
UART1_Write(HardUART_Rx);
}
}
}

Comment