Code: Select all
UART_Set_Active(@UART1_Read, @UART1_Write, @UART1_Data_Ready, @UART1_Tx_Idle); ' set UART1 active
uart1_rd = UART1_Read() ; ' Read message through UART1
UART_Set_Active(@UART2_Read, @UART2_Write, @UART2_Data_Ready, @UART2_Tx_Idle); ' set UART2 active
uart2_rd = UART2_Read() ; ' Read through UART2
UART_Set_Active(@UART1_Read, @UART1_Write, @UART1_Data_Ready, @UART1_Tx_Idle); ' set UART1 active
uart1_rd = UART1_Read() ; ' Read message through UART1
......
Code: Select all
sub procedure UART2interrupt() iv IVT_UART_2 ilevel 6 ics ICS_AUTO
uart2_rd = UART2_Read() ' read the received data
U2RXIF_bit = 0
end sub
sub procedure UART1interrupt() iv IVT_UART_1 ilevel 6 ics ICS_AUTO
if OERR_bit = 1 then
OERR_bit = 0 ' overrun error and clear it otherwise the port will be jammed
end if
Uart1_rd = U1RxReg
U1RXIF_bit = 0
end sub
UART_Set_Active(@UART2_Read, @UART2_Write, @UART2_Data_Ready, @UART2_Tx_Idle) ' set only once
U1RXIE_bit = 1 ' enable uart1 received interrupt
U2RXIE_bit = 1 ' enable uart2 received interrupt
Thanks for advice in advance.