Code:
#CONFIG __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON
__config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
__config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
__config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_ON
__config _CONFIG5, _CP_OFF & _CPD_OFF
#ENDCONFIG
DEFINE OSC 32
include "codesize.pbp"
define Measure 1
DEFINE DEBUG_REG PORTB
DEFINE DEBUG_BIT 7
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 0
PORTB.7 = 1
trisb=%01100111
anselb=0
UsartFlag var byte
RecvData var byte[5]
CNTr VAR BYTE
UsartRight con 1
UsartSlave con 2
Usart0 con 3
UsartC con 1
UsartE con 2
UsartD con 3
UsartF con 4
Usart2 con 0
Usart3 con 5
cntr=10
RecvData[0]=UsartRight
RecvData[1]=UsartSlave
RecvData[2]=Usart0
DEBUG 13,10,"go"
LOOOP:
pause 500
UsartFlag = 1
RecvData[3]= cntr dig 1
RecvData[4]= cntr dig 0
cntr=cntr+5
if cntr = 50 then cntr=10
DEBUG 13,10, #cntr
latb.4=1
@ StartSize(rc)
' IF (UsartFlag = 1) then
' ARRAYREAD RecvData,5,itsadud,[wait(UsartRight,UsartSlave,Usart0)]
' select case RecvData[3]
' case UsartC
' IF RecvData[4] == Usart2 THEN
' GOSUB DisplayCOM1
' else
' GOSUB DisplayCOM1_Standby
' endif
' case UsartD
' IF RecvData[4] == Usart2 THEN
' GOSUB DisplayCOM2
' else
' GOSUB DisplayCOM2_Standby
' endif
' case UsartE
' IF RecvData[4] == Usart2 THEN
' GOSUB DisplayNAV1
' else
' GOSUB DisplayNAV1_Standby
' endif
' case UsartF
' IF RecvData[4] == Usart2 THEN
' GOSUB DisplayNAV2
' else
' GOSUB DisplayNAV2_Standby
' endif
' end select
' itsadud:
' UsartFlag = 0
' endif
IF (UsartFlag = 1) then
ARRAYREAD RecvData,5,MainloopContinue1,[wait(UsartRight,UsartSlave,Usart0,UsartC,Usart2)]
GOSUB DisplayCOM1
UsartFlag = 0
MainloopContinue1:
endif
IF (UsartFlag = 1) then
ARRAYREAD RecvData,5,MainloopContinue2,[wait(UsartRight,UsartSlave,Usart0,UsartC,Usart3)]
GOSUB DisplayCOM1_Standby
UsartFlag = 0
MainloopContinue2:
endif
IF (UsartFlag = 1) then
ARRAYREAD RecvData,5,MainloopContinue3,[wait(UsartRight,UsartSlave,Usart0,UsartE,Usart2)]
GOSUB DisplayCOM2
UsartFlag = 0
MainloopContinue3:
endif
IF (UsartFlag = 1) then
ARRAYREAD RecvData,5,MainloopContinue4,[wait(UsartRight,UsartSlave,Usart0,UsartE,Usart3)]
GOSUB DisplayCOM2_Standby
UsartFlag = 0
MainloopContinue4:
endif
IF (UsartFlag = 1) then
ARRAYREAD RecvData,5,MainloopContinue5,[wait(UsartRight,UsartSlave,Usart0,UsartD,Usart2)]
GOSUB DisplayNAV1
UsartFlag = 0
MainloopContinue5:
endif
IF (UsartFlag = 1) then
ARRAYREAD RecvData,5,MainloopContinue6,[wait(UsartRight,UsartSlave,Usart0,UsartD,Usart3)]
GOSUB DisplayNAV1_Standby
UsartFlag = 0
MainloopContinue6:
endif
IF (UsartFlag = 1) then
ARRAYREAD RecvData,5,MainloopContinue7,[wait(UsartRight,UsartSlave,Usart0,UsartF,Usart2)]
GOSUB DisplayNAV2
UsartFlag = 0
MainloopContinue7:
endif
IF (UsartFlag = 1) then
ARRAYREAD RecvData,5,MainloopContinue8,[wait(UsartRight,UsartSlave,Usart0,UsartF,Usart3)]
GOSUB DisplayNAV2_Standby
UsartFlag = 0
MainloopContinue8:
endif
@ EndSize(rc)
latb.4=0
GOTO LOOOP
DisplayCOM1:
DisplayCOM1_Standby:
DisplayCOM2:
DisplayCOM2_Standby:
DisplayNAV1:
DisplayNAV1_Standby:
DisplayNAV2:
DisplayNAV2_Standby:
DEBUG " ",#RecvData[3]," ",#RecvData[4]
RETURN
Bookmarks