; ; FILE: downlink.ips ; PURPOSE: To dowlink a single data product in page 8 or two products in page 8 and 9 ; When on the redundant side, use pages 12 and 13. ; METHOD: ; Input: $IPRL_DL_PARAM - high word of page to downlink ; $IPRL_DL_PARAM+1 - OPTIONAL high word of second page to downlink ; HISTORY: Written 25-Aug-95 by M.Morrison ; 30-Aug-95 (MDM) - Changed the name and allowed either of the ; two pages to be downlinked ; 7-Sep-95 (MDM) - Changes to make it work ; 18-Sep-95 (MDM) - More changes to get it to work ; 18-Oct-95 (MDM) - Moved how 550 word math is done ; - Called subroutine to check if the previous downlink is finished ; and to abort it if it is not finished ; - Fixed up how HRDINIT work is done (in other routines) ; 26-Oct-95 (MDM) - Corrected error where I was looking at R3077 (DEP Reg 5) ; instead of R3075 (DEP Reg 3) to see if VC mode was active ; 16-Nov-95 (MDM) - Removed all debug statements ; 29-Jan-96 (MDM) - Added setting of R26 before savemode call during re-try to ; start downlink ; - Added SAVEMODE instruction after call to RESET_TLM. It ; only takes effect if RESET_TLM found a problem and set R26 ; - Corrected the re-try logic ; - Added a wait between the SAVEMODE and retry ; QSR_DL_1PAGE:: SETREG $IPRL_DL_NPAGE 1 GOTO &COMMON_CODE QSR_DL_2PAGE:: SETREG $IPRL_DL_NPAGE 2 GOTO &COMMON_CODE COMMON_CODE: SETREG $IPRL_DL_CHECKED 0 ;Initialized the "waited already" flag to 0 BRANCHIF R3075 &DONE ;if no VC = 0 then don't bother SETREGS $IPRL_DL_DLPAGE_LST 2 0x4000 0x4800 ;pages 8 and 9 are the telemetry pages for primary side BRANCHEQ R33 0 &USE_PRIMARY_LST SETREGS $IPRL_DL_DLPAGE_LST 2 0x6000 0x6800 ;pages 12 and 13 are the telemetry pages for redundant side ???? USE_PRIMARY_LST: COPYREG $IPRL_DL_DLPAGE_LST $IPRL_TLM_PAGE CALLQUE $QSR_TLM_RESET ;check to see if there is something still coming out of that page SAVEMODE ;abort if necessary COPYREG $IPRL_DL_DLPAGE_LST+1 $IPRL_TLM_PAGE CALLQUE $QSR_TLM_RESET SAVEMODE SETREG $IPRL_DL_LOOP 0 ;first loop through COPYREG $IPRL_DL_DLPAGE_LST $IPRL_DL_DLPAGE ;one downlink page setup at a time COPYREG $IPRL_DL_PARAM $IPRL_DL_INPAGE ;copy the input source page SETREG $IPRP_DL_NWORDS_PNTR $IPRL_DL_NWORDS ;where to save the number of words to downlink LOOP_CODE: ;-------- decode the source page info COPYREG $IPRL_DL_INPAGE $IPRL_HDECODE_PARAM ;copy the source page value into a known fixed place (always come from page 0) SETREG $IPRL_HDECODE_PARAM+1 0x0000 ;there is no destination page - just set it to page 0 ;CAUTION: HDECODE copies the source params into the destination page slot CALLQUE $QSR_DO_HDECODE ;decode the value COPYRI2D $IPRP_HDECODE_ADDR $IPRL_HEAD_WORK 10 ;copy the register list to a fixed working area ;------- Copy the data to the downlink page (if necessary) COPYRD2D $IPRL_HEAD_WORK $IPRL_DL_COPY 3 ;copy the source page (l,h) (copies an extra word) ;;ADDADR $IPRL_DL_COPY $IPRL_NEG_550W $IPRL_DL_COPY ;shift the source address back the header number of words REGADD $IPRL_DL_COPY $IPRL_NEG_550W $IPRL_DL_COPY ;shift the source address back the header number of words SETREG $IPRL_DL_COPY+2 0 ;set the destination low word to zero COPYREG $IPRL_DL_DLPAGE $IPRL_DL_COPY+3 ;copy the high word destination page COPYRD2D $IPRL_HEAD_WORK+8 $IPRL_DL_COPY+4 3 ;copy the number of words (l,h) (copies an extra word) COPYRD2I $IPRL_DL_COPY+4 $IPRP_DL_NWORDS_PNTR 3 ;copy how many words to downlink (not including the header) ADDADR $IPRL_DL_COPY+4 $IPRL_POS_550W $IPRL_DL_COPY+4 ;increment the number of words by 550 words (the header) ;------- Check to see if a copy is even needed REGSUB $IPRL_HEAD_WORK+1 $IPRL_DL_DLPAGE $IPRL_DL_TEMP ;compare the source/DL pages BRANCHEQ $IPRL_DL_TEMP 0 &NO_COPY_NEEDED ;if data is already in the downlink page, don't do the move _MOVBLKI $IPRL_DL_COPY ;move the data to the page NO_COPY_NEEDED: BRANCHEQ $IPRL_DL_NPAGE 1 &DL1PAGE COPYREG $IPRL_DL_DLPAGE_LST+1 $IPRL_DL_DLPAGE ;one downlink page setup at a time COPYREG $IPRL_DL_PARAM+1 $IPRL_DL_INPAGE ;copy the input source page SETREG $IPRP_DL_NWORDS_PNTR $IPRL_DL_NWORDS+3 ;where to save the number of words to downlink ADDREGD $IPRL_DL_LOOP 1 ;increment the loop counter BRANCHEQ $IPRL_DL_LOOP 1 &LOOP_CODE ;do the copy portion of the code for the second page ;------------ Two page downlink command DL2PAGE: BRANCHEQ $IPRL_HEAD_WORK+3 0 &DL2_RAW DL2_COMP: ;--------------- Downlink 2 Pages in COMPRESSED mode BRANCHEQ R33 0 &DL2_COMP_PRIM DL2_COMP_REDUN: GETQADR $IPRL_DL_QADDR_REDO START2HR 0x49 0x6000 0x6800 $IPRL_DL_NWORDS $IPRL_DL_NWORDS+3 GOTO &WAITING DL2_COMP_PRIM: GETQADR $IPRL_DL_QADDR_REDO START2HR 0x49 0x4000 0x4800 $IPRL_DL_NWORDS $IPRL_DL_NWORDS+3 GOTO &WAITING DL2_RAW: ;--------------- Downlink 2 Pages in RAW mode BRANCHEQ R33 0 &DL2_RAW_PRIM DL2_RAW_REDUN: GETQADR $IPRL_DL_QADDR_REDO START2HR 0x4b 0x6000 0x6800 $IPRL_DL_NWORDS $IPRL_DL_NWORDS+3 GOTO &WAITING DL2_RAW_PRIM: GETQADR $IPRL_DL_QADDR_REDO START2HR 0x4b 0x4000 0x4800 $IPRL_DL_NWORDS $IPRL_DL_NWORDS+3 GOTO &WAITING ;------------ One page downlink command section DL1PAGE: BRANCHEQ $IPRL_HEAD_WORK+3 0 &DL1_RAW DL1_COMP: ;--------------- Downlink 1 Page in COMPRESSED mode BRANCHEQ R33 0 &DL1_COMP_PRIM DL1_COMP_REDUN: GETQADR $IPRL_DL_QADDR_REDO START1HR 0x01 0x6000 $IPRL_DL_NWORDS GOTO &WAITING DL1_COMP_PRIM: GETQADR $IPRL_DL_QADDR_REDO START1HR 0x01 0x4000 $IPRL_DL_NWORDS GOTO &WAITING DL1_RAW: ;--------------- Downlink 1 Page in RAW mode BRANCHEQ R33 0 &DL1_RAW_PRIM DL1_RAW_REDUN: GETQADR $IPRL_DL_QADDR_REDO START1HR 0x03 0x6000 $IPRL_DL_NWORDS GOTO &WAITING DL1_RAW_PRIM: GETQADR $IPRL_DL_QADDR_REDO START1HR 0x03 0x4000 $IPRL_DL_NWORDS GOTO &WAITING WAITING: ;-------------- Check to see that the downlink actually started BRANCHEQ $IPRL_DL_CHECKED 1 &DONE ;already did the wait once, get out SETREG $IPRL_DL_CHECKED 1 SETREG R143 16 PURGELST R136 ;wait 82 msec before checking the page BRANCHEQ R33 0 &CHECK_PRIM CHECK_REDUN: BRANCHNR 0x6000 &DONE ;The page got busy ==> all ok GOTO &PROBLEM CHECK_PRIM: BRANCHNR 0x4000 &DONE ;The page got busy ==> all ok GOTO &PROBLEM PROBLEM: SETREG R26 1 SAVEMODE ;save the state, throw an error and reset the IP SETREG R143 16 PURGELST R136 ;wait 82 msec before retrying GOTOREG $IPRL_DL_QADDR_REDO ;Go back and issue the command again DONE: RTNQUE