;############################################################################## ;# ;# Defenition of Reserved Registers ;# ;############################################################################## #def rstack=r13 ; one entry program stack #def rio=r14 ; IO address #def rram=r15 ; RAM address ;############################################################################## ;# ;# Pseudo Infinite Loop at IMEM Address 0 ;# ;############################################################################## jmpr cc_uncond, 0 ;############################################################################## ;# ;# 0x0100: IRQ Clear Handling Routine ;# ;############################################################################## ;# ;# ;############################################################################## org 0x100 ; set absolut program code start address jmpr cc_uncond, 0 ;############################################################################## ;# ;# 0x0200: IRQ Acquisition Handling Routine ;# ;############################################################################## ;# ;# ;############################################################################## org 0x200 ; set absolut program code start address #ifdef cpu0 mov 4, r0 ; subroutine interface: channel number mov 0x042, rram ; subroutine interface: destination offset #endif ; address (DRAM) #ifdef cpu1 mov 4, r0 ; subroutine interface: channel number mov 0x02C, rram ; subroutine interface: destination offset #endif ; address (DRAM) #ifdef cpu2 mov 4, r0 ; subroutine interface: channel number mov 0x016, rram ; subroutine interface: destination offset #endif ; address (DRAM) #ifdef cpu3 mov 5, r0 ; subroutine interface: channel number mov 0x000, rram ; subroutine interface: destination offset #endif ; address (DRAM) shl 2, rram, rram ; transform word to byte address I200L0: mov 64, r1 ; subroutine interface: number of time bins mvpcr +2, rstack ; subroutine: save return address jmp cc_uncond, ChRO ; call -> Readout of one channel sub r0, c1, r0 ; increase channel number jmp cc_ges, I200L0 ; procees with remaining channels mov 3, r0 ; subroutine interface: active CPU number mvpcr +2, rstack ; subroutine: save return address jmp cc_uncond, Stop3 ; call -> Single CPU Mode mvpcr +2, rstack ; subroutine: save return address jmp cc_uncond, SCSNsync ; call -> SCSN synchronization mvpcr +2, rstack ; subroutine: save return address jmp cc_uncond, NIL ; call -> Low Power Mode Transition ;############################################################################## ;# ;# Readout of one channel ;# ;############################################################################## ;# ;# Interface: ;# ;# Input: r0 CPU relative channel number ;# r1 number of time bins to read (>0, multiple of three) ;# rram destination offset address (DRAM) ;# ;# Output: r1 zero ;# rram last data word address ;# ;############################################################################## ChRO: mov 0x800, rio ; load event buffer offset address (PIO) mov 0x040, r2 ; load channel size mul32 r2, r0, r2 ; calculate channel offset address nop ; relative to event buffer address add r2, rio, rio ; calculate total channel offset address ;############################################## ;# BEGIN data transfer loop ChRoL: ;############################################## lpio rio, r3 ; initial read has to be done twice due to lpio+ r3 ; memory delay (synchronous read) lpio+ r4 lpio+ r5 shl 11, r5, r5 ; combine three (10+1) bit data words or r5, r4, r5 ; to one (32=10+1+10+1+10) bit data word shl 11, r5, r5 ; the parity bit of the highest data word or r5, r3, r5 ; is lost sra+ r5 sub r1, c3, r1 jmp cc_leu, rstack ; return from subroutine jmp cc_uncond, ChRoL ;############################################## ;# END data transfer loop ;############################################## ;############################################################################## ;# ;# Single CPU Mode ;# ;############################################################################## ;# ;# The clocks of all but one CPU are disabled. ;# ;# Interface: ;# ;# Input: r0 number of active CPU ;# ;############################################################################## Stop3: cmp r0, c5 jmp cc_eq, rstack ; active CPU: return from subroutine #ifdef cpu0 iext b0000_0000_0001_0000_0000_0000 mov b0000_0000_0001_0000_0000_0000, r0 #endif #ifdef cpu1 iext b0000_0000_0010_0000_0000_0000 mov b0000_0000_0010_0000_0000_0000, r0 #endif #ifdef cpu2 iext b0000_0000_0100_0000_0000_1000 mov b0000_0000_0100_0000_0000_1000, r0 #endif #ifdef cpu3 iext b0000_0000_1000_0000_0000_0000 mov b0000_0000_1000_0000_0000_0000, r0 #endif jmpr cc_busy, 0 ; wait for GIO access sgio r0, 0xA05 ; transmit clocking command jmpr cc_uncond, 0 ; pseudo infinite loop ;############################################################################## ;# ;# Low Power Mode Transition ;# ;############################################################################## ;# ;# Put chip in low power mode and enter pseudo infinite loop. ;# ;############################################################################## NIL: mov 0x012, r0 ; low power mode code jmpr cc_busy, 0 ; wait for GIO access sgio r0, 0xA04 ; transmit GSM command jmpr cc_uncond, 0 ; pseudo infinite loop ;############################################################################## ;# ;# SCSN synchronization ;# ;############################################################################## ;# ;# This function sends a synchronization signal to the ;# SCSN master. Thus it can start another SCSN sequence. ;# ;# ;# Therefore a rising edge is being performed on one of the single ended ;# bidirectional outputs. ;# ;############################################################################## SCSNsync: mov 0, r0 ; load one and zero into two registers mov 1, r1 iext 0x3178 ; output pad enable at GIO address 0x3178 mov 0x3178, rio ; (see SEBDEN in the TRAP user manual) jmpr cc_busy, 0 ; wait for GIO access sgio+ r1 ; write value and increment address to 0x3179 ; (see SEBDOU in the TRAP user manual) jmpr cc_busy, 0 ; wait for GIO access sgio r0, rio ; set output to zero jmpr cc_busy, 0 ; wait for GIO access sgio r1, rio ; set output to one (this is the rising edge) jmpr cc_busy, 0 ; wait for GIO access sgio r0, rio ; set output to zero jmp cc_uncond, rstack ; return from subroutine