/*************************************************************************** * * * PIB Board Program * * 25/02/2003 v3.8 * * * * JF Huppert * * Fr Machefert * * U Bassler * * LPNHE / D0 Paris * * Université Paris VI - Paris VII * * * * serial bus format : bit 0 = clock (out) * * bit 1 = enable (out) * * bit 2 = data out * * bit 3 = trig out * * bit 4 = data in * * bit 5 = trig in * * bit 6 = trig-in ack (out) * * bit 7 = trigger veto (out) : veto = 1 * * * * * * PIB board VME address : * * let H be the position of the rotary switch on the PIB board * * H defines bits 20,21,22,23 of the A24 vme board address * * Vme address space is 1 MB from 0xH00000 to 0xHFFFFF * * * * 0xH00000 is the CPU control word addr : write either * * 0x1 to reset board, or * * SHUTDOWN_MASK to reset board & send emergency shutdown to all pulsers * * 0xH02000 is the start address of the board's vme ram * * * * * * * * PIB memory map : * * read from pulser area write to pulser area * * (PIB) (EPICS) * * * * * * 0x628 |-------------------| * * |ramp: pat.32 cur3 | * * 0x624 |-------------------| * * |ramp: pat.32 cur2 | * * 0x620 |-------------------| * * |ramp: pat.32 cur1 | * * 0x61C |-------------------| * * |ramp: pat.32 cmd * * 0x618 |-------------------| * * . * * . * * . * * 0x440 |-------------------| * * |ramp: pat. 2 cur1 | * * 0x43C |-------------------| * * |ramp: pat. 2 cmd * * 0x438 |-------------------| * * |ramp: pat. 1 cur3 | * * 0x434 |-------------------| * * |ramp: pat. 1 cur2 | * * 0x430 |-------------------| * * |ramp: pat. 1 cur1 | * * 0x42C |-------------------| * * |ramp: pat. 1 cmd | * * |-------------------| 0x428 |-------------------| * * |ramp: nb patterns | |ramp: nb patterns | * * |-------------------| 0x424 |-------------------| * * |ramp: current pat | | | * * |-------------------| 0x420 |-------------------| * * |ramp: error tag | | | * * |-------------------| 0x41C |-------------------| * * |ramp: current evt | | | * * |-------------------| 0x418 |-------------------| * * |ramp: current step | |icd_scaling | * * |-------------------| 0x414 |-------------------| * * |ramp: nb of steps | |ramp: nb of steps | * * |-------------------| 0x410 |-------------------| * * |ramp: step size | |ramp: step size | * * |-------------------| 0x40C |-------------------| * * |ramp: nb evts/step | |ramp: nb evts/step | * * |-------------------| 0x408 |-------------------| * * | alive | |Wait | * * |-------------------| 0x404 |-------------------| * * | PIB ident | | | * * |-------------------| 0x400 |-------------------| * * | error | | .... | * * | message pul 15 | | .... | * * |-------------------| |-------------------| * * | error code pul 15 | | | * * |-------------------| |-------------------| * * | .... | | .... | * * | .... | | .... | * * | .... | | .... | * * |-------------------| 0x220 |-------------------| * * | error | | .... | * * | message pul 0 | | .... | * * |-------------------| 0x204 |-------------------| * * | error code pul 0 | | | * * |-------------------| 0x200 |-------------------| * * | .... | | .... | * * | .... | | .... | * * | .... | | .... | * * |-------------------| 0x188 |-------------------| * * | pulser15 | | pulser15 | * * |-------------------| 0x170 |-------------------| * * | pulser14 | | .... | * * |-------------------| 0x158 |-------------------| * * | pulser13 | | .... | * * |-------------------| 0x140 |-------------------| * * | pulser12 | | .... | * * |-------------------| 0x128 |-------------------| * * | pulser11 | | .... | * * |-------------------| 0x110 |-------------------| * * | pulser10 | | .... | * * |-------------------| 0xf8 |-------------------| * * | pulser9 | | .... | * * |-------------------| 0xe0 |-------------------| * * | pulser8 | | .... | * * |-------------------| 0xc8 |-------------------| * * | pulser7 | | .... | * * |-------------------| 0xb0 |-------------------| * * | pulser6 | | .... | * * |-------------------| 0x98 |-------------------| * * | pulser5 | | .... | * * |-------------------| 0x80 |-------------------| * * | pulser4 | | .... | * * |-------------------| 0x68 |-------------------| * * | pulser3 | | .... | * * |-------------------| 0x50 |-------------------| * * | pulser2 | | .... | * * |-------------------| 0x38 |-------------------| * * | pulser1 | | .... | * * |-------------------| 0x20 |-------------------| * * | pulser0 | | pulser0 | * * | .... | | .... | * * | data | | data | * * |-------------------| 0x8 |-------------------| * * | validity | | on/off status | * * |-------------------| 0x4 |-------------------| * * | Poll & status | |Poll, req, pulsers | * * |-------------------| 0x0 |-------------------| * * * * Vme addr (0xH02000) Vme addr (0xH05000) * * * * * * * * Poll,req,pulsers format : bit 0 - 15 = pulsers to address * * : bit 24 - 30 = request code * * : bit 31 = Poll bit * * * * Poll & status format : bit 0 - 15 = pulser error bits * * : bit 31 = global busy bit * * * * validity & on/off format : bit 0 - 15 = validity or on/off pulser bits * * * * status : bit(n) = 1 ==> error on pulser n * * validity : bit(n) = 0 ==> pulser off or busy, depending on PIB Poll bit * * : (means pulser off when PIB Poll bit = 0, * * : otherwise means pulser is busy) * * pulser : bit(n) = 1 ==> service requested for pulser n * * on/off : bit(n) = 1 ==> pulser on * * * * Wait: number of instructions for wait function * * * * request 0 - 8000: pulser w/r (whole config) * * request 1 - 8100: pulser read (whole config) * * request 2 - 8200: pulser write (whole config) * * request 7 - 8700: shutdown (DAC = 0 & cmd enable off for all pulsers) * * * * request 25 - 9800: broadcast configuration w/r * * * * request 32 - a000: send trigger 0-1-0 low16-bits of req word is loop count* * request 33 - a100: send trigger inv 1-0-1 " " * * * * request 48 - b000 : test (copy write-to-pulser data to read-from-pulser) * * request 49 - b100 : test cycle timing by repeatedly sending CMD req * * request 50 - b200 : test trig : receiving a trig in -> send a trig-in ack * * * * request 64 - c000 : ramp ABORT * * request 65 - c100 : DAC ramp * * request 66 - c200 : Delay ramp * * * * * * pulser data : word 0 bits 29 - 24 command enable * * bits 17 - 0 dac * * word 1 bits 23 - 16 delay 2 * * bits 15 - 8 delay 1 * * bits 7 - 0 delay 0 * * word 2 bits 23 - 16 delay 5 * * bits 15 - 8 delay 4 * * bits 7 - 0 delay 3 * * word 3 channel enable 31 - 0 * * word 4 channel enable 63 - 32 * * word 5 channel enable 95 - 64 * * * * ramp data : error tag bits 31 - 16 code of last error * * bits 15 - 0 error count * * * * pattern: nb patterns = 0 pattern on pulser as configured * * nb patterns < 32 loop over up to 32 patterns * * word 1 channel enable 31 - 0 * * word 2 channel enable 63 - 32 * * word 3 channel enable 95 - 64 * * on reset : * * * * ident is set to 0 to signal that PIB is initializing ... * * validity bits are all set to 0 (invalid) * * pulser on/off bits are all set to 0 (off) * * hardware & software initializations * * when PIB board is ready, ident is set to "version ident" * * * * * * then PIB enters infinite loop : * * * * it polls write_to_pulser status Poll bit & increments alive counter * * until Poll bit is set. * * when Poll bit set (i.e. a request is received) : * * set Poll bit of read_from_pulser status (send ack) * * execute request depending on request_code (bits 24-30 of status wd * * reset Poll bit of write_to_pulser status * * reset Poll bit of read_from_pulser status * * * * to do a ramp : * * * * for a DAC ramp : first, using the pulser w/r request, program all the * * concerned pulsers for command enable, delays 0 to 5, channel enable * * then write ramp step, number of steps and number of events per steps * * to the corresponding EPICS area * * then, send DAC ramp request, with initial DAC value as DAC value * * * * for a DELAY ramp : first, using the pulser w/r request, program all * * the concerned pulsers for DAC value, command enable, channel enable * * then write ramp step, number of steps and number of events per steps * * to the corresponding EPICS area * * then, send DELAY ramp request, with initial delays value as delays * * * * at any time a ramp may be interrupted by writing a RAMP_ABORT request * * to the request area of EPICS * * errors may be checked by reading the ramp_error_tag of the PIB area * * * * ERROR CODES: * * * * errors bits are written for each pulser into the "pulser error bit word" * * and the corresponding messages into "pulser error message". * * If a pulser is in error mode, the bit corresponding to the pulser number * * is set in the "Poll & status" word * * * * NO_ERR 0x0 NO_ERR * * UNREAD 0xFF UNREAD * * READBACK_ADDR_ERR 0x100 ADDR_READBACK_ERR * * DAC_ERR 0x110 DAC_VALUE_RDBCK_ERR * * CMD_ERR 0x111 COMMAND_ENABLE_RDBCK_ERR * * ENABLE_ERR 0x112 CHANNEL_ENABLE_RDBCK_ERR * * DELAY0_ERR 0x120 DELAY0_VALUE_RDBCK_ERR * * DELAY1_ERR 0x121 DELAY1_VALUE_RDBCK_ERR * * DELAY2_ERR 0x122 DELAY2_VALUE_RDBCK_ERR * * DELAY3_ERR 0x123 DELAY3_VALUE_RDBCK_ERR * * DELAY4_ERR 0x124 DELAY4_VALUE_RDBCK_ERR * * DELAY5_ERR 0x125 DELAY5_VALUE_RDBCK_ERR * * * ****************************************************************************/ /* * updates and modifications * * 23/10/00 UB include loop over up to 32 patterns in ramp mecanism * * 23/05/01 UB version 3 * extend SHUTDOWN to all pulser componets * implement broadcast of pulser configuration * modified pulser invalidation * download of initial pulser configuration in Ramp mecanism * 31/01/02 UB take some downloads out of the shutdown option * 31/01/02 UB reduce the code size: remove if of nb_pat being 0! * attention: nb_pat should always be 1! * remove BROADCASTS except CONFIG * 14/03/02 UB DEBUGGING: * correct pointer to ramp pattern configuration * correct increment of current pattern number * braquetts missing on if and else * 30/04/02 UB Debugging: * put Read_From_Pul_Ramp_CE counter to Delay-Ramp * Pulser configuraiton loop for pattenr download closed correctly in DAC/DELAY ramps * impeletemnt correct treatment for nopattern loop: * additional variable pat_request set to 0/1, default nb_pat=1 in loop * 14/06/02 UB putting a "wait" to take into account the "channel-enable" * download signal for pattern-raps * correct bug for current pattern-number * Bug-fix current pattern-number * 14/11/02 UB bug-fix: valid-flag moved after "wait" * 24/02/03 UB pulser shutdown during PIB-start-up * remove wait limitation * 17/03/03 UB read-back of pulser status after initial shutdown * 22/03/03 UB remove use of Error-code "SHUTDOWN", shutdown treated as normal * download * 26/05/03 UB read-back of pulser status after initial shutdown to all pulse * areas * 31/03/04 UB ICD-scale factor implemented * additional DAC-value download for pattern ramps * Wait-word extended to a long integer. * pattern parameters set to 0 in shutdown * * 06/05/04 UB DAC-value read-back in delay pattern loop fixed * 04/06/04 UB intialize and put event-counter to -1 during download and =0 after wait * icrement Pib_alive counter during wait-function * initialize nb of wait-instructions by 0xffff * ****************************************************************************/