;*** filter wheel patch removed 15-Apr-2005 ;*** (used to generate p78F_epc.prc) ; ==== ISUAL Flight Software -- Univ of California, Berkeley, SSL ==== ; sc.a -- Management of Spacecraft Data Buffers org 22B9h ; (load-address of this module in FSW 7.8) ; ; Revision History: ; 18-Dec-2002 - SPG - ISUAL Flight Software rev 7.3 ; First Official Release ; 7-Apr-2003 ; Activated interlock to prevent PVCF building ; while PVCFs are being transmitted to the spacecraft ; 29-May-2003 ; call CCSDS_HSKP instead of CCSDS_SEND ; 6-Aug-2003 ; fixed bug in 4-byte add ; 8-Aug-2003 ; new MM allocations ; 11-Aug-03 - restored table from rev 7.6 ; 8-Oct-2003 - MAX_NPVCFS=3840 (was 4094) ; 20-Oct-2003 ; restart buffer output order when there ; has been an MM upset ; 21-Oct-2003 ; - activate interlock of TM while SC is sending ; - change max NPVCFS from 4094 to 4095 ; 30-Oct-2003 - abort buffer xmt if MM fault ; Astrium: Maximum number of PVCFs which may be sent to the ; spacecraft in one transmission is 4095. ; 4095 x 1108/4 = 1134315 32-bit MM words ; which is 114EEB in hex ; Low 10 bits of instrument buffer addresses must be zero, ; so we make everything like that, and round up to 115000 hex ; Two Spacecraft Data Buffers are stored in Mass memory ; Spacecraft data Buffer 1 is stored at the beginning ; of Mass Memory (address 00000000h) ; Spacecraft data Buffer 2 is stored following it ; (at address 00115000h) ; Next available memory is 0022A000h ; Compression List (16*11 = 176 words - B0h) ; is located between the SC buffers at 00114EEB..00114F9A ; default MM allocation parameters ; fields commented BPL_xxx are copied into GBL_BPL_xxx ; (these are written to the DCM during initialization) ; fields commented PP_xxx are copied into GBL_PP_xxx ; (these are written to the DCM when PVCF processing is initialized) default_BPL: ; MM addr of Status word db 00h,022h,0A0h,000h ; BPL_STATUS ; MM addr of Program Load Block (4 words, followed by data array) db 00h,022h,0A0h,001h ; BPL_PLB ; MM addr of PVCF command list (allow 32 words) db 00h,022h,0A3h,000h ; BPL_CMD ; MM addr of MMCB list (16 44-byte MMCBs = 176 words - B0h) db 00h,011h,04Eh,0EBh ; BPL_MMCB ; MM addr of debug word (1 word) db 00h,022h,0A3h,020h ; BPL_DEBUG ; MM addr of start of readout allocations ; (low 10 bits must be zero) db 00h,022h,0A4h,000h ; (to GBL_RO_BASE) default_PP: ; op=0 db 0,0,0,0 ; PP_OP ; addr of 1st Spacecraft Buffer db 00h,000h,000h,000h ; PP_MMSC1 ; addr of 2nd Spacecraft Buffer db 00h,011h,050h,000h ; PP_MMSC2 ; max number of PVCFs per buffer db 00h,000h,0Fh,0FFh ; PP_MAXNPVCFS (4095) ; addr of word giving current number of PVCFs in SC1 db 00h,022h,0A3h,021h ; PP_N_SC1 ; addr of word giving current number of PVCFs in SC2 db 00h,022h,0A3h,022h ; PP_N_SC2 ; Virtual Channel Frame Counter to assign to next PVCF db 0,0,0,0 ; PP_N_VCFC ; addr where Packet headers will be stored by DPU (20 bytes- 5 words) db 00h,022h,0A3h,024h ; PP_N_MMHDRS include sc.i include ccsds.i include pvcf.i include mm.i include clock.i include task.i include util.i include gbl.i include debug.i include ioports.i ; Mass Memory addresses are 32 bits ; and represent 4-byte words pvcf_MM_address ds 4 current_store_buffer equ GBL_CURRENT_SC_BUFFER sc_MM_address ds 4 ; size of PVCF = 1108 bytes, or 277 32-bit words (115 hex) ; as a 4-byte number C1108 db 0,0,01h,15h sq01 ds 2 ; source sequence for MBR packet SC_INIT: ; Copy two tables into Global Memory. ; This one (Base Parameter List - BPL) gives the ; Mass Memory addresses of various DCM control words. lxi h,default_BPL lxi d,GBL_BPL_STATUS mvi c,6*4 ; (6 to include RO_BASE) call copy_bytes ; This table defines the location and size ; of the spacecraft buffers. lxi h,default_PP lxi d,GBL_PP_OP mvi c,8*4 call copy_bytes lxi h,0 shld sq01 mvi a,0 sta flush ; Start the task which manages sending a Spacecraft Buffer ; to the spacecraft. lxi d,sc_task lxi h,GBL_SC_STACK+stack_size call task_new ret flush ds 1 SC_FLUSH: ; force transmission of SC Buffers push psw mvi a,1 sta flush pop psw ret ; ===Task to Send Science Telemetry to Spacecraft === count ds 2 ; little endian mbr_count ds 2 ; big endian ; ==== SC Task === sc_task: ; waiting for Buffer #1 to fill scw1: call task ; If flush requested, flush 1, then 2 lda flush ; flush requested? cpi 1 jnz nof1 ; flush both buffers call send1 call send2 mvi a,0 sta flush ; reset flush flag jmp sc_task ; start over nof1: lda GBL_SC_BUF1 ; test for Buf1 ready-to-send scw1a: cpi 1 jnz scw1 ; not ready ; send buffer 1 call send1 ; Waiting for Buffer 2 to fill scw2: call task ; if MM upset, go back to waiting for buffer 1 lda GBL_PVSTART cpi 0 jz scw1 ; 0 means upset ; If flush requested, flush 2, then 1 lda flush cpi 1 jnz nof2 call send2 call send1 mvi a,0 sta flush ; reset flush flag jmp sc_task ; start over nof2: lda GBL_SC_BUF2 ; send buffer 2 scw2a: cpi 1 jnz scw2 lda GBL_PVSTART cpi 0 jz scw1 call send2 jmp sc_task ; Subroutine to send SC Buffer 1 send1: ; get number of PVCFs to send lda GBL_SOH+71 sta count+1 ; (store it little-endian) mov c,a sta mbr_count ; (store it big-endian) lda GBL_SOH+72 sta count sta mbr_count+1 ora c ; nonzero? rz ; zero; nothing to send ; add to overall PVCF total (big endian, in SOH) lhld count lda GBL_SOH+19 mov d,a lda GBL_SOH+20 mov e,a dad d mov a,h sta GBL_SOH+19 mov a,l sta GBL_SOH+20 ; Set starting MM address lxi h,GBL_PP_MMSC1 lxi d,sc_MM_address mvi c,4 call copy_bytes ; Send the buffer to the spacecraft call send_buffer b1mt: ; Buffer 1 is now empty mvi a,0 sta GBL_SC_BUF1 ; copy PVCF count for checker lhld GBL_SOH+71 shld GBL_N1 ; zero the buffer counter shown in SOH lxi h,0 shld GBL_SOH+71 ; SC1_NPVCFS ; zero the counter in MM lxi h,GBL_ZERO lxi d,GBL_PP_N_SC1 lxi b,1 call mm_store ret ; Subroutine to send SC buffer 2 send2: ; get number of PVCVs to send lda GBL_SOH+73 sta count+1 ; (store it little-endian) mov c,a sta mbr_count ; (store it big-endian) lda GBL_SOH+74 sta count sta mbr_count+1 ora c ; nonzero? rz ; zero; nothing to send ; add to overall PVCF total (big endian, in SOH) lhld count lda GBL_SOH+19 mov d,a lda GBL_SOH+20 mov e,a dad d mov a,h sta GBL_SOH+19 mov a,l sta GBL_SOH+20 ; Set starting MM address lxi h,GBL_PP_MMSC2 lxi d,sc_MM_address mvi c,4 call copy_bytes ; Send the buffer to the spacecraft call send_buffer ; Buffer 2 is now empty b2mt: mvi a,0 sta GBL_SC_BUF2 ; copy PVCF count for checker lhld GBL_SOH+73 shld GBL_N2 ; zero the buffer's PVCF counter shown in SOH lxi h,0 shld GBL_SOH+73 ; SC2_NPVCFS ; zero the counter in MM lxi h,GBL_ZERO lxi d,GBL_PP_N_SC2 lxi b,1 call mm_store ret SC_SEND_MBR: ; Signal spacecraft that FSW wishes to transmit ; a block of PVCFs. ; HL - points to count word (number of PVCFs) push psw push d push h push h ; >>save pointer to count word mvi a,0 sta GBL_MBR_REPLY ; reset MBR reply flag ; Send MBR message to Spacecraft mvi a,01h ; ApID 701 lxi b,20 ; total packet length is 20 lhld sq01 ; this ApID's source sequence number xchg ; in DE pop h ; <