<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://cmbr.phas.ubc.ca/mcewiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=24.82.145.130</id>
	<title>MCEWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://cmbr.phas.ubc.ca/mcewiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=24.82.145.130"/>
	<link rel="alternate" type="text/html" href="https://cmbr.phas.ubc.ca/mcewiki/index.php/Special:Contributions/24.82.145.130"/>
	<updated>2026-09-17T17:50:58Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>https://cmbr.phas.ubc.ca/mcewiki/index.php?title=Data_mode&amp;diff=2572</id>
		<title>Data mode</title>
		<link rel="alternate" type="text/html" href="https://cmbr.phas.ubc.ca/mcewiki/index.php?title=Data_mode&amp;diff=2572"/>
		<updated>2009-03-18T18:22:18Z</updated>

		<summary type="html">&lt;p&gt;24.82.145.130: /* Data Modes and Windowing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= MCE Data Types =&lt;br /&gt;
There are 5 types of data that the MCE can return in data packets:  &lt;br /&gt;
# '''sq1_fb''': the feedback applied by the MCE to the 1&amp;lt;sup&amp;gt;st&amp;lt;/sup&amp;gt; stage SQUIDs:&lt;br /&gt;
#* &amp;lt;math&amp;gt;sq1\_fb_{n+1} = \frac{1}{2^{12}} \left[\left(gainp \times error_{n}\right) + \left(gaini \times \sum_{i=1}^{n} error_i\right) + \left(gaind \times [error_{n} - error_{n-1}]\right) \right]&amp;lt;/math&amp;gt;&lt;br /&gt;
#* Where &amp;lt;math&amp;gt;\sum_{i=1}^n error_i&amp;lt;/math&amp;gt; is the integral of the error from the moment the pixel was locked, and &lt;br /&gt;
#* Where &amp;lt;math&amp;gt;\left[error_{n} - error_{n-1} \right]&amp;lt;/math&amp;gt; is the difference between the current error value and the previous one.&lt;br /&gt;
#* Where 'n' is the frame period index&lt;br /&gt;
#* Where 'i' is the frame period index since the PID-loop was locked (servo_mode = 3)&lt;br /&gt;
# '''error''':  the error calculated from the Series-Array signals sampled by the ADCs:&lt;br /&gt;
#* &amp;lt;math&amp;gt;error = \sum_{i=1}^{sample\_num} (adc\_reading_{i} - adc\_offset)&amp;lt;/math&amp;gt;&lt;br /&gt;
# '''sq1_fb_filtered''': the low-pass filtered SQ1 feedback (see [[ Digital 4-pole Butterworth Low-pass filter | 4-pole Butterworth low-pass filter ]]).  The effective DC gain, including quantization error, is approximately:&lt;br /&gt;
#* &amp;lt;math&amp;gt;sq1\_fb\_filtered_{n} \simeq 1218 \times \left[sq1\_fb_{n-1}\right]&amp;lt;/math&amp;gt;&lt;br /&gt;
# '''num_flux_jumps''':  the value stored in the flux-jump counter.  See [[ Flux jumping ]].&lt;br /&gt;
#* &amp;lt;math&amp;gt;num\_flux\_jumps_{n} = \frac{1}{flux\_quanta} \left[(sq1\_fb_{n}) - (sq1\_fb\_applied\_to\_DAC_{n})\right]   &amp;lt;/math&amp;gt;&lt;br /&gt;
# '''raw_data''':  raw data sampled @ 50 MHz.  See [[ Raw-mode readout ]].&lt;br /&gt;
#* &amp;lt;math&amp;gt;raw\_data = \left[adc\_reading - adc\_offset\right]&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Data Modes and Windowing =&lt;br /&gt;
* Current as of Readout Card firmware revision 4.0.c)&lt;br /&gt;
* The data modes below offer the types of data listed above in various combinations, and with different windowings.  Each data point in a data packet is 32 bits wide, and may have several types of data packed into it.  The table below specifies the different packings.&lt;br /&gt;
* The table below makes liberal use of variables '''sq1_fb, error, sq1_fb_filtered, num_flux_jumps,''' and '''raw_data''', which are defined above.  &lt;br /&gt;
* Generally, a data packet contains one data point per pixel, although there are exceptions to this:&lt;br /&gt;
** Fast Data: packets contain data for a subset of pixels to allow readout at a faster rate:  [[ High rate acquisition ]].&lt;br /&gt;
** Raw Data: packets contain a 50MHz time stream of data starting from row zero.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Data Mode !! Summary !! Pixel-Data Description !! RC Firmware Revision &lt;br /&gt;
|-&lt;br /&gt;
| 0 &lt;br /&gt;
|| Error &lt;br /&gt;
|| 32b (signed) co-added Error signal err[31:0]. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Break-down by bit-field:&lt;br /&gt;
* [31:0] '''error_mode0''' = error &lt;br /&gt;
&lt;br /&gt;
|| all&lt;br /&gt;
|-&lt;br /&gt;
| 1 &lt;br /&gt;
|| Feedback &lt;br /&gt;
||'''When servo_mode = 3:'''&lt;br /&gt;
32b (signed) SQ1 Feedback data fb[31:0]. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Break-down by bit-field:&lt;br /&gt;
* [31:0] '''feedback_mode1a''' = sq1_fb * 2&amp;lt;sup&amp;gt;12&amp;lt;/sup&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because servo_mode=3 is the normal running condition, only feedback_mode1a is supported by most MAS programs.  The non-servoing form, feedback_mode1b, is included here for completeness.&lt;br /&gt;
&lt;br /&gt;
'''When servo_mode != 3:'''&lt;br /&gt;
32b (signed) SQ1 Feedback from the rc? fb_const registers. These are DAC values. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Break-down by bit-field:&lt;br /&gt;
* [31:0] '''feedback_mode1b''' = sq1_fb&lt;br /&gt;
 &lt;br /&gt;
|| all&lt;br /&gt;
|-&lt;br /&gt;
| 2 &lt;br /&gt;
|| Filtered feedback &lt;br /&gt;
||32b (signed) low-pass filtered SQ1 feedback data fb[31:0].   &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Break-down by bit-field:&lt;br /&gt;
* [31:0] '''filtered_fb_mode2''' = sq1_fb_filtered&lt;br /&gt;
&lt;br /&gt;
|| 2.0.5 and later&lt;br /&gt;
|-&lt;br /&gt;
| 3 &lt;br /&gt;
|| Raw 50 MHz &lt;br /&gt;
|| Raw 50 MHz ADC samples raw[13:i], where i=0 in rev. 4.3.7 and i=6 in all previous firmware. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Break-down by bit-field:&lt;br /&gt;
* [31:0] '''raw_mode3''' = raw_data / (2&amp;lt;sup&amp;gt;i&amp;lt;/sup&amp;gt;),&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|| Only 3.0.6, 3.0.16, 3.0.25, 4.1.7, 4.2.7, 4.3.7&lt;br /&gt;
|-&lt;br /&gt;
| 4 &lt;br /&gt;
|| 18:14 Mixed &lt;br /&gt;
||Signed 18b SQ1 feedback fb[31] &amp;amp; fb[28:12] + signed 14b coadded error signal err[31] &amp;amp; err[12:0].   &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Break-down by bit-field:&lt;br /&gt;
* [31:14] '''feedback_mode4''' = sq1_fb &lt;br /&gt;
* [13:0] '''error_mode4''' = error&lt;br /&gt;
&lt;br /&gt;
|| 2.0.9 and later&lt;br /&gt;
|-&lt;br /&gt;
| 5 &lt;br /&gt;
|| 24:8 mixed &lt;br /&gt;
|| Signed 24b SQ1 feedback fb[31:8] + signed 8b num_flux_jumps fj[7:0]. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Break-down by bit-field:&lt;br /&gt;
* [31:8] '''feedback_mode5''' = sq1_fb * 2&amp;lt;sup&amp;gt;4&amp;lt;/sup&amp;gt;&lt;br /&gt;
* [7:0] '''num_flux_jumps_mode5''' = num_flux_jumps&lt;br /&gt;
&lt;br /&gt;
|| all&lt;br /&gt;
|-&lt;br /&gt;
| 6 obsolete &lt;br /&gt;
|| 18:14 mixed&lt;br /&gt;
|| Signed 18b filtered data filter[31] &amp;amp; filter[27:11] + signed 14b coadded error signal err[31] &amp;amp; err[12:0]. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Break-down by bit-field:&lt;br /&gt;
* [31:13] '''filtered_fb_mode6''' = sq1_fb_filtered / (2&amp;lt;sup&amp;gt;11&amp;lt;/sup&amp;gt;)&lt;br /&gt;
* [12:0] '''error_mode6''' = error&lt;br /&gt;
&lt;br /&gt;
|| 3.0.30 to 4.0.6 only&lt;br /&gt;
|-&lt;br /&gt;
| 7 &lt;br /&gt;
|| 22:10 mixed&lt;br /&gt;
|| Signed 22b filtered data filter[31] &amp;amp; filter[27:7] + signed 10b coadded error signal err[31] &amp;amp; err[12:4]. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Break-down by bit-field:&lt;br /&gt;
* [31:10] '''filtered_fb_mode7''' = sq1_fb_filtered / (2&amp;lt;sup&amp;gt;7&amp;lt;/sup&amp;gt;)&lt;br /&gt;
* [9:0] '''error_mode7''' = error / (2&amp;lt;sup&amp;gt;4&amp;lt;/sup&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
|| 4.0.2 and later&lt;br /&gt;
|-&lt;br /&gt;
| 8 obsolete&lt;br /&gt;
||24:8 mixed &lt;br /&gt;
|| Signed 24b filtered data filter[31:8] + signed 8b num_flux_jumps fj[7:0]. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Break-down by bit-field:&lt;br /&gt;
* [31:8] '''filtered_fb_mode8''' = sq1_fb_filtered / (2&amp;lt;sup&amp;gt;8&amp;lt;/sup&amp;gt;)&lt;br /&gt;
* [7:0] '''num_flux_jumps_mode8''' = num_flux_jumps&lt;br /&gt;
&lt;br /&gt;
|| 4.0.4 only&lt;br /&gt;
|-&lt;br /&gt;
| 9 &lt;br /&gt;
|| 24:8 mixed &lt;br /&gt;
|| Signed 24b filtered data filter[31] &amp;amp; filter[23:1] + signed 8b num_flux_jumps fj[7:0]. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Break-down by bit-field:&lt;br /&gt;
* [31:8] '''filtered_fb_mode9''' = sq1_fb_filtered/ (2&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;)&lt;br /&gt;
* [7:0] '''num_flux_jumps_mode9''' = num_flux_jumps &lt;br /&gt;
&lt;br /&gt;
|| 4.0.5 and later&lt;br /&gt;
|-&lt;br /&gt;
| 10 &lt;br /&gt;
|| 25:7 mixed &lt;br /&gt;
|| Signed 25b filtered data filter[27:3] + signed 7b num_flux_jumps fj[6:0]. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Break-down by bit-field:&lt;br /&gt;
* [31:7] '''filtered_fb_mode10''' = sq1_fb_filtered / (2&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;)&lt;br /&gt;
* [6:0] '''num_flux_jumps_mode10''' = num_flux_jumps&lt;br /&gt;
&lt;br /&gt;
|| 4.1.6, 4.0.b and later&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Automatic loading of data with mas_data.pro =&lt;br /&gt;
Please note that, by default, [[ mas_data.pro ]] will rescale data in the following way:&lt;br /&gt;
* error signals are rescaled to match the units of data mode 0.&lt;br /&gt;
* sq1 feedback is rescaled to sq1_feedback (DAC) units (i.e. data mode 1 divided by 2&amp;lt;sup&amp;gt;12&amp;lt;/sup&amp;gt;)&lt;br /&gt;
* filtered sq1 feedback is rescaled to the units of data mode 2.&lt;br /&gt;
&lt;br /&gt;
This means the IDL user does not need to worry about the windowing of the different data modes for many applications.&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
* [[ MCE firmware ]]&lt;br /&gt;
* [[ Main Page ]]&lt;/div&gt;</summary>
		<author><name>24.82.145.130</name></author>
		
	</entry>
	<entry>
		<id>https://cmbr.phas.ubc.ca/mcewiki/index.php?title=MCE_hardware&amp;diff=2571</id>
		<title>MCE hardware</title>
		<link rel="alternate" type="text/html" href="https://cmbr.phas.ubc.ca/mcewiki/index.php?title=MCE_hardware&amp;diff=2571"/>
		<updated>2009-02-18T20:09:57Z</updated>

		<summary type="html">&lt;p&gt;24.82.145.130: /* MCEv2 5-MDM Instrument Backplane design notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== MCEv2 5-MDM Instrument Backplane design notes ==&lt;br /&gt;
Here is the schematic posted for review: &lt;br /&gt;
[[http://www.phas.ubc.ca/~mce/projects/spider-spud-bicep2/system/MCEv2_Inst_Backplane/design/elec/C587-201_A_5MDM_IB/C587-201_INST_BP.pdf | IB schematics]]&lt;br /&gt;
&lt;br /&gt;
For the record, here are some of the design decisions, currently not too late to change them:&lt;br /&gt;
&lt;br /&gt;
* '''implementation of configurable jumpers '''&lt;br /&gt;
In previous backplane designs, jumpers were implemented either as PCB traces or solder jumpers. The former had the problem of not being configurable as we had to cut traces. The latter had the problem that the assembler wouldn't put the solder jumpers on and since they are not on the BOM, it became hard to track whether they were done or not. Therefore, we settled on the following solution for the new design:&lt;br /&gt;
** Jumpers for signal pairs have reference designators of JPn and JNn (eg. JP1 and JN1 are signal pair jumpers)&lt;br /&gt;
** These jumpers are called out on the BOM as zero ohm resistors or DNP (do not populate) parts&lt;br /&gt;
** Zero ohm resistors will not be used for connect ground planes, copper traces will be used&lt;br /&gt;
&lt;br /&gt;
* ''' MDM routing of low-noise bias lines ''' &lt;br /&gt;
How to divide up the Low Noise Bias Signals between the new Bias Cards.&lt;br /&gt;
** We need to maintain compatibility with existing Bias Cards which should ground these new backplane signal lines.&lt;br /&gt;
** Maximizing the number of Low Noise Bias Signals we could get 10 on each of BC1-BC3 for a total of 30.&lt;br /&gt;
** How we route them to the MDM connectors is limited but we have a few options, what seems to be best to me is&lt;br /&gt;
*** P2 gets LN_BIAS_00 to 08 &lt;br /&gt;
*** P3 gets LN_BIAS_09 to 15 (P3 also has DET_BIAS_ORG and PXL_HTR)&lt;br /&gt;
*** P4 gets LN_BIAS_16 to 23 with 1 spare signal (pair)&lt;br /&gt;
*** P5 gets LN_BIAS_24 to 29 with 3 spare signal (pair)&lt;br /&gt;
&lt;br /&gt;
* '''Mechanical and Cosmetic Changes '''&lt;br /&gt;
** Include provisions for clamping Hirose connectors&lt;br /&gt;
** Reorder Resistor Reference Designators so they are in order on the PCB&lt;br /&gt;
&lt;br /&gt;
* '''Design Concerns '''&lt;br /&gt;
** A considerable number of signal lines now have 0805 zero ohm jumpers which may be difficult to layout in the space available&lt;/div&gt;</summary>
		<author><name>24.82.145.130</name></author>
		
	</entry>
	<entry>
		<id>https://cmbr.phas.ubc.ca/mcewiki/index.php?title=MAS&amp;diff=2570</id>
		<title>MAS</title>
		<link rel="alternate" type="text/html" href="https://cmbr.phas.ubc.ca/mcewiki/index.php?title=MAS&amp;diff=2570"/>
		<updated>2009-02-17T19:15:34Z</updated>

		<summary type="html">&lt;p&gt;24.82.145.130: /* Usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Usage ==&lt;br /&gt;
&lt;br /&gt;
* System applications&lt;br /&gt;
** [[mce_cmd]]&lt;br /&gt;
** [[mce_status]]&lt;br /&gt;
** [[maslog]]&lt;br /&gt;
** [[dsp_cmd]]&lt;br /&gt;
** [[ MAS Command line how-to ]]&lt;br /&gt;
&lt;br /&gt;
* Special applications&lt;br /&gt;
** [[ sq1_servo and sq2_servo ]]&lt;br /&gt;
** [[ mce_ramp ]]&lt;br /&gt;
** [[ psc_status ]]&lt;br /&gt;
&lt;br /&gt;
* Utilities&lt;br /&gt;
&lt;br /&gt;
* MAS configuration&lt;br /&gt;
** [[ MAS start/stop ]]&lt;br /&gt;
** [[ mce.cfg ]]&lt;br /&gt;
** [[ mas.cfg ]]&lt;br /&gt;
** [[ MAS array_id and array_list | array_id and array_list ]]&lt;br /&gt;
&lt;br /&gt;
* MAS file formats&lt;br /&gt;
** [[ Runfile format v2 ]]&lt;br /&gt;
** [[ MCE flat-file format ]]&lt;br /&gt;
&lt;br /&gt;
* Utilities for loading data&lt;br /&gt;
** IDL [[ mas_data.pro | data ]] and [[ mas_runfile.pro and mas_runparam.pro | runfile]] scripts&lt;br /&gt;
** [[ Python data and runfile modules ]]&lt;br /&gt;
&lt;br /&gt;
* IDL scripts&lt;br /&gt;
** [[ auto_setup_squids.pro ]]&lt;br /&gt;
&lt;br /&gt;
* Help&lt;br /&gt;
** [[ MCE: Helper programs ]]&lt;br /&gt;
** [[ MAS Cheat Sheet ]]&lt;br /&gt;
** [[ MCE Recovery During Acquisition ]]&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
* [[ MAS Bug List ]]&lt;br /&gt;
* [[ MAS to-do ]]&lt;br /&gt;
* [[ MAS feature requests ]]&lt;br /&gt;
&lt;br /&gt;
== Installation / configuration ==&lt;br /&gt;
&lt;br /&gt;
* [[ MAS PC requirements and initial setup | PC requirements and initial setup]]&lt;br /&gt;
* [[ MAS OS setup | OS setup]]&lt;br /&gt;
* [[ MAS user setup ]]&lt;br /&gt;
* [[ MAS kernel patch compilation | kernel patch compilation]]&lt;br /&gt;
* [[ MAS svn repository | SVN repository]]&lt;br /&gt;
* [[ Hardware goodlist/badlist ]]&lt;br /&gt;
&lt;br /&gt;
== Trouble-shooting ==&lt;br /&gt;
&lt;br /&gt;
* [[ MAS malfunction diagnosis | diagnosis ]]&lt;/div&gt;</summary>
		<author><name>24.82.145.130</name></author>
		
	</entry>
	<entry>
		<id>https://cmbr.phas.ubc.ca/mcewiki/index.php?title=Auto-setup_(IDL)&amp;diff=2563</id>
		<title>Auto-setup (IDL)</title>
		<link rel="alternate" type="text/html" href="https://cmbr.phas.ubc.ca/mcewiki/index.php?title=Auto-setup_(IDL)&amp;diff=2563"/>
		<updated>2009-02-05T20:38:31Z</updated>

		<summary type="html">&lt;p&gt;24.82.145.130: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This script tunes a squid array using the MCE.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The steps in the tuning are roughly the following:&lt;br /&gt;
# &amp;quot;SA ramp&amp;quot;: Ramp the SA feedback to select the SA output value of the lock-point (at this stage it is also possible to ramp the SA bias to find a V-phi curve of maximum amplitide). &lt;br /&gt;
# &amp;quot;SQ2 servo&amp;quot;: Ramp the SQ2 feedback and servo the SA feedback to determine the SA feedback at lock-point.&lt;br /&gt;
# &amp;quot;SQ1 servo&amp;quot;: For a single SQ1 in each column , ramp the SQ1 feedback and servo the SQ2 feedback to determine the SQ2 feedback at lock-point.&lt;br /&gt;
# &amp;quot;SQ1 ramp&amp;quot;: For each SQ1, ramp the SQ1 feedback and determine the SA output value correction (ADC_offset) of the lock-point.&lt;br /&gt;
&lt;br /&gt;
In addition to these, there is a final acquisition of a few hundred frames to evaluate the lock of each detector.  This is called &amp;quot;frametest&amp;quot;.  Following this test, and independent of it, the servo parameters of channels known to be dead or problematic are turned off.&lt;br /&gt;
&lt;br /&gt;
== Tuning parameters ==&lt;br /&gt;
&lt;br /&gt;
Most tuning parameters (such as biases, servo gains, SQ1 servo row selections) are defined in the [[experiment.cfg]] file.  Contact UBC for help with this.&lt;br /&gt;
&lt;br /&gt;
== Auto script ==&lt;br /&gt;
&lt;br /&gt;
Command-line access is via auto_setup_squids_sh, called like this:&lt;br /&gt;
  auto_setup_squids_sh &amp;lt;level&amp;gt; &amp;lt;cards&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where:&lt;br /&gt;
* level is one of 0,1,2 and selects what parts of the tuning to perform&lt;br /&gt;
** 0 (default): full tuning of all stages of the array.&lt;br /&gt;
** 1: perform only the &amp;quot;SQ1 servo&amp;quot; and the &amp;quot;SQ1 ramp&amp;quot; &lt;br /&gt;
** 2: perform only the &amp;quot;SQ1 ramp&amp;quot;&lt;br /&gt;
* cards is one of s,1,2,3,4, with s the default:&lt;br /&gt;
** Note for &amp;quot;s&amp;quot;: this will tune all *4* readout cards.  'rcs' support for systems with 2 readout cards is still in development.&lt;br /&gt;
&lt;br /&gt;
== IDL calling parameters ==&lt;br /&gt;
&lt;br /&gt;
The IDL function declaration is (as of r397)&lt;br /&gt;
 pro auto_setup_squids, COLUMN=column, ROW=row, RCs=rcs, interactive=interactive, text=text, numrows=numrows, note=note, ramp_sa_bias=ramp_sa_bias, check_bias=check_bias, short=short, quiet=quiet&lt;br /&gt;
&lt;br /&gt;
Parameters that continue to be supported are:&lt;br /&gt;
* '''rcs''' (int array): an array of readout card numbers to tune.  e.g. [1,2].&lt;br /&gt;
* '''note''' (string): a string to pass to the DB registration program (for logging)&lt;br /&gt;
* '''short''' (int): causes tuning of only particular stages of the array (useful for correcting minor drifts due to changing thermal or magnetic environments)&lt;br /&gt;
* '''ramp_sa_bias''' (switch): forces ramping of the SA bias during the SA ramp step.  This can also be controlled through experiment.cfg&lt;br /&gt;
* '''check_bias''' (switch): causes the script to check for biasing of the SA and SQ2.  If these are off, they are biased on and the script delays execution for a couple of minutes to let the system equilibrate. &lt;br /&gt;
* '''quiet''' (int): when set to 1 or 2, reduces text output to the terminal.&lt;br /&gt;
&lt;br /&gt;
Parameters that no one really uses but might still work:&lt;br /&gt;
* '''column''' and '''row''' (int array): columns and rows to plot in the final frametest step.&lt;br /&gt;
&lt;br /&gt;
Parameters that are probably broken or definitely meaningless:&lt;br /&gt;
* '''interactive'''&lt;br /&gt;
* '''text'''&lt;/div&gt;</summary>
		<author><name>24.82.145.130</name></author>
		
	</entry>
	<entry>
		<id>https://cmbr.phas.ubc.ca/mcewiki/index.php?title=MAS&amp;diff=2560</id>
		<title>MAS</title>
		<link rel="alternate" type="text/html" href="https://cmbr.phas.ubc.ca/mcewiki/index.php?title=MAS&amp;diff=2560"/>
		<updated>2009-02-05T20:01:55Z</updated>

		<summary type="html">&lt;p&gt;24.82.145.130: /* Usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Usage ==&lt;br /&gt;
&lt;br /&gt;
* System applications&lt;br /&gt;
** [[mce_cmd]]&lt;br /&gt;
** [[mce_status]]&lt;br /&gt;
** [[maslog]]&lt;br /&gt;
** [[dsp_cmd]]&lt;br /&gt;
** [[ MAS Command line how-to ]]&lt;br /&gt;
&lt;br /&gt;
* Special applications&lt;br /&gt;
** [[ sq1_servo and sq2_servo ]]&lt;br /&gt;
** [[ mce_ramp ]]&lt;br /&gt;
** [[ psc_status ]]&lt;br /&gt;
&lt;br /&gt;
* Utilities&lt;br /&gt;
&lt;br /&gt;
* MAS configuration&lt;br /&gt;
** [[ MAS start/stop ]]&lt;br /&gt;
** [[ mce.cfg ]]&lt;br /&gt;
** [[ mas.cfg ]]&lt;br /&gt;
** [[ MAS array_id and array_list | array_id and array_list ]]&lt;br /&gt;
&lt;br /&gt;
* MAS file formats&lt;br /&gt;
** [[ Runfile format v2 ]]&lt;br /&gt;
** [[ MCE flat-file format ]]&lt;br /&gt;
&lt;br /&gt;
* IDL functions&lt;br /&gt;
** [[ mas_data.pro ]]&lt;br /&gt;
** [[ mas_runfile.pro and mas_runparam.pro ]]&lt;br /&gt;
** [[ Other useful IDL routines ]]&lt;br /&gt;
&lt;br /&gt;
* IDL scripts&lt;br /&gt;
** [[ auto_setup_squids.pro ]]&lt;br /&gt;
&lt;br /&gt;
* Help&lt;br /&gt;
** [[ MCE: Helper programs ]]&lt;br /&gt;
** [[ MAS Cheat Sheet ]]&lt;br /&gt;
** [[ MCE Recovery During Acquisition ]]&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
* [[ MAS Bug List ]]&lt;br /&gt;
* [[ MAS to-do ]]&lt;br /&gt;
* [[ MAS feature requests ]]&lt;br /&gt;
&lt;br /&gt;
== Installation / configuration ==&lt;br /&gt;
&lt;br /&gt;
* [[ MAS PC requirements and initial setup | PC requirements and initial setup]]&lt;br /&gt;
* [[ MAS OS setup | OS setup]]&lt;br /&gt;
* [[ MAS user setup ]]&lt;br /&gt;
* [[ MAS kernel patch compilation | kernel patch compilation]]&lt;br /&gt;
* [[ MAS svn repository | SVN repository]]&lt;br /&gt;
* [[ Hardware goodlist/badlist ]]&lt;br /&gt;
&lt;br /&gt;
== Trouble-shooting ==&lt;br /&gt;
&lt;br /&gt;
* [[ MAS malfunction diagnosis | diagnosis ]]&lt;/div&gt;</summary>
		<author><name>24.82.145.130</name></author>
		
	</entry>
	<entry>
		<id>https://cmbr.phas.ubc.ca/mcewiki/index.php?title=PCI_card_firmware&amp;diff=2528</id>
		<title>PCI card firmware</title>
		<link rel="alternate" type="text/html" href="https://cmbr.phas.ubc.ca/mcewiki/index.php?title=PCI_card_firmware&amp;diff=2528"/>
		<updated>2009-01-14T04:03:36Z</updated>

		<summary type="html">&lt;p&gt;24.82.145.130: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[ PCI card bug list ]]&lt;br /&gt;
* [[ PCI card to-do]]&lt;br /&gt;
* [[ PCI card code assembly on Linux ]]&lt;br /&gt;
* [[ PCI card hacking ]]&lt;/div&gt;</summary>
		<author><name>24.82.145.130</name></author>
		
	</entry>
	<entry>
		<id>https://cmbr.phas.ubc.ca/mcewiki/index.php?title=PCI_card_hacking&amp;diff=2527</id>
		<title>PCI card hacking</title>
		<link rel="alternate" type="text/html" href="https://cmbr.phas.ubc.ca/mcewiki/index.php?title=PCI_card_hacking&amp;diff=2527"/>
		<updated>2009-01-14T04:02:37Z</updated>

		<summary type="html">&lt;p&gt;24.82.145.130: /* MCE command, reply and data buffers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes using dsp_cmd and mce_cmd to debug MCE/PCI card communication issues.  These instructions can be used to resolve questions like &amp;quot;is the data getting dropped by the PCI card, or does it never arrive at the PCI card?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== RAM areas on the DSP ==&lt;br /&gt;
&lt;br /&gt;
The DSP has 3 RAM banks, known as X, Y, and P.  User data is in X and Y, while the program code is in P.  By default, all three banks contain something like 2k x 16bits.  On our hardware, however, the Y bank has been extended with an external SRAM to 8M x 16bits.&lt;br /&gt;
&lt;br /&gt;
In our firmware, X memory is used to store ordinary variables while Y memory is used for large buffers.&lt;br /&gt;
&lt;br /&gt;
== Reading and writing DSP RAM with dsp_cmd ==&lt;br /&gt;
&lt;br /&gt;
We can use dsp_cmd to read back the values of variables and buffers in the PCI card RAM.  This is done as follows:&lt;br /&gt;
 mhasse@mce-ubc-2:~$ dsp_cmd -x read X 0&lt;br /&gt;
 This is dsp_cmd version MAS/slotpc/327&lt;br /&gt;
 Line   0 : ok : X[0] = 0x208&lt;br /&gt;
&lt;br /&gt;
We can also write.  Don't write to X or P memory unless you really know what you're doing.&lt;br /&gt;
 mhasse@mce-ubc-2:~$ dsp_cmd -x write Y 0 0x1234&lt;br /&gt;
 This is dsp_cmd version MAS/slotpc/327&lt;br /&gt;
 Line   0 : ok&lt;br /&gt;
&lt;br /&gt;
It is convenient to define a few functions to make this hacking easier (you can just dump this into your bash session, or put it in a file and run &amp;quot;source file&amp;quot; whenever you want the functions to be available): &lt;br /&gt;
 function pciread {&lt;br /&gt;
     dsp_cmd -qpx read $1 $2 | cut -d' ' -f5&lt;br /&gt;
 }&lt;br /&gt;
 function pciwrite {&lt;br /&gt;
     dsp_cmd -qpx write $1 $2 $3&lt;br /&gt;
 }&lt;br /&gt;
 function pcidump {&lt;br /&gt;
     # usage: pcidump &amp;lt;BANK&amp;gt; &amp;lt;START&amp;gt; &amp;lt;COUNT&amp;gt;&lt;br /&gt;
     for i in `seq -f '%9.0f' $2 $(( $2 + $3 - 1 ))`; do printf &amp;quot;%s %#8x 0x%06x\n&amp;quot; $1 $i `pciread $1 $i`; done&lt;br /&gt;
 }&lt;br /&gt;
 function pciwash {&lt;br /&gt;
     # usage: pciwash &amp;lt;BANK&amp;gt; &amp;lt;START&amp;gt; &amp;lt;COUNT&amp;gt; &amp;lt;VALUE&amp;gt;&lt;br /&gt;
     for i in `seq -f '%9.0f' $2 $(( $2 + $3 - 1 ))`; do pciwrite $1 $i $4; done&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Then you use them like this:&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pciread x 0&lt;br /&gt;
 0x208&lt;br /&gt;
 mhasse@mce-ubc-2:~ pciwrite y 0 0x1234&lt;br /&gt;
 &lt;br /&gt;
 mhasse@mce-ubc-2:~$ pcidump Y 0x100000 4&lt;br /&gt;
 Y 0x100000 0x004f4b&lt;br /&gt;
 Y 0x100001 0x00474f&lt;br /&gt;
 Y 0x100002 0x000016&lt;br /&gt;
 Y 0x100003 0x000003&lt;br /&gt;
&lt;br /&gt;
== MCE command, reply and data buffers ==&lt;br /&gt;
&lt;br /&gt;
We can inspect the DSP's buffers if we know their addresses.  This depends on DSP code firmware revision.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; width=400&lt;br /&gt;
! Version !! Data !! Reply    !! Command&lt;br /&gt;
|-&lt;br /&gt;
| U0104 and earlier   ||    0 ||        0 ||    0x200&lt;br /&gt;
|-&lt;br /&gt;
| U0105   ||    0 || 0x100000 || 0x200000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Notes about data buffers:'''&lt;br /&gt;
* because DSP words are 24 bits wide, and MCE words are 32 bits wide, 32-bit data is broken into pairs of 16-bit words, with the lower order bits coming first.  So the 32-bit value 0x12345678 is stored as [0x005678, 0x001234]. &lt;br /&gt;
* in reply and data packets, the preamble, packet type, and frame size are stripped off.  These will not appear in the buffers in Y memory.  They are available at special locations in X memory, however.&lt;br /&gt;
&lt;br /&gt;
(Incidentally, the collision between the &amp;quot;data&amp;quot; and reply/command buffers in version U0104 and earlier is why U0105 is required to be able to issue STOP or other MCE commands during frame acquisition.)&lt;br /&gt;
&lt;br /&gt;
== DSP internal variables ==&lt;br /&gt;
&lt;br /&gt;
There are a few DSP internal variables, stored in X memory, that are of use in comm. hacking:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Name                 !! Address(U0104) !! Address(U0105) !! Description&lt;br /&gt;
|-&lt;br /&gt;
| STATUS               || 0x00            || 0x00          || Status (and modes) of DSP, see bit break-down below&lt;br /&gt;
|-&lt;br /&gt;
| MODE                 || n/a             || 0x01          || Flags configuring certain modes of the DSP&lt;br /&gt;
|-&lt;br /&gt;
| HEAD_W3_0            || 0x21            || 0x14          || Type of last reply or data packet, 'DA' or 'RP' &lt;br /&gt;
|-&lt;br /&gt;
| PACKET_SIZE_LOW      || 0x23            || n/a           || Size of latest reply or data packet, in 16 bit words&lt;br /&gt;
|-&lt;br /&gt;
| PACKET_SIZE          || n/a             || 0x2B          || Size of latest reply or data packet, in 32 bit words&lt;br /&gt;
|-&lt;br /&gt;
| QT_FRAME_SIZE        || 0x53            || 0x3D          || The expected size of data packets in bytes&lt;br /&gt;
|-&lt;br /&gt;
| FRAME_COUNT          || 0x01            || 0x02          || Number of DA packets received from the MCE (including discards) &lt;br /&gt;
|-&lt;br /&gt;
| QT_DROPS             || 0x5A            || 0x44          || Number of data packets dropped due to full PC RAM buffer  &lt;br /&gt;
|-&lt;br /&gt;
| RP_DROPS             || n/a             || 0x48          || Number of reply packets dropped due to PC RAM buffer unavailable (quiet_RP mode only)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Currently, the number of packets that are dropped due to a packet size mismatch between PACKET_SIZE and QT_FRAME_SIZE is not recorded explicitly.  However, such packets will cause FRAME_COUNT to increment.&lt;br /&gt;
&lt;br /&gt;
All of the above variables, except STATUS, MODE, and FRAME_COUNT are cleared by a DSP_RESET.  You can zero the frame count manually using pciwrite.&lt;br /&gt;
&lt;br /&gt;
(Incidentally, the addresses in the table above are determined from the .lod symbol table of the assembler output.)&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Firmware version U0105 is assumed below.  Use the functions defined above.&lt;br /&gt;
&lt;br /&gt;
=== Inspect a command packet ===&lt;br /&gt;
&lt;br /&gt;
Note that in current firmware, packets are copied into the DSP buffer *at the same time* as they are transmitted to the MCE.  So if your data appears in the DSP buffer, it has also been sent out on the FO transmitter.&lt;br /&gt;
&lt;br /&gt;
We issue&lt;br /&gt;
 mhasse@mce-ubc-2:~$ mce_cmd -x &amp;quot;wb cc led 7&amp;quot;&lt;br /&gt;
and then inspect the packet in the DSP buffer:&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pcidump y 0x200000 128&lt;br /&gt;
 y 0x200000 0x00a5a5&lt;br /&gt;
 y 0x200001 0x00a5a5&lt;br /&gt;
 y 0x200002 0x005a5a&lt;br /&gt;
 y 0x200003 0x005a5a&lt;br /&gt;
 y 0x200004 0x002020&lt;br /&gt;
 y 0x200005 0x005742&lt;br /&gt;
 y 0x200006 0x000002&lt;br /&gt;
 y 0x200007 0x000099&lt;br /&gt;
 y 0x200008 0x000000&lt;br /&gt;
 y 0x200009 0x000001&lt;br /&gt;
 y 0x20000a 0x000000&lt;br /&gt;
 y 0x20000b 0x000007&lt;br /&gt;
 y 0x20000c 0x000000&lt;br /&gt;
 y 0x20000d 0x000000&lt;br /&gt;
 ...&lt;br /&gt;
 y 0x20007c 0x000000&lt;br /&gt;
 y 0x20007d 0x000000&lt;br /&gt;
 y 0x20007e 0x002022&lt;br /&gt;
 y 0x20007f 0x0057dd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Is the MCE returning data? ===&lt;br /&gt;
&lt;br /&gt;
Suppose &amp;quot;mce_run&amp;quot; is blocking without data and we want to check the frame data.  We first fill the data buffer with a signature we can recognize:&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pciwash y 0x0 4096 0x123456&lt;br /&gt;
&lt;br /&gt;
and we may as well zero the frame counter, too.&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pciwrite x 0x2 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then we trigger a go somehow.  mce_run is easiest.&lt;br /&gt;
 mhasse@mce-ubc-2:~$ mce_run test_1935 1 1&lt;br /&gt;
 RUNFILE_NAME=/data/cryo/current_data//test_1935.run&lt;br /&gt;
 FRAME_BASENAME=/data/cryo/current_data//test_1935&lt;br /&gt;
&lt;br /&gt;
This hangs, so we Ctrl-C it.&lt;br /&gt;
&lt;br /&gt;
We confirm that the DSP received a single frame from the MCE:&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pciread x 2&lt;br /&gt;
 0x1&lt;br /&gt;
&lt;br /&gt;
Now inspect the data buffer:&lt;br /&gt;
 pcidump y 0x0 4096 &amp;gt; dump.txt&lt;br /&gt;
(This can take a while.) Inspecting the output we see reasonable data up to address 0x200:&lt;br /&gt;
 ...&lt;br /&gt;
 y    0x1fd 0x00ffff&lt;br /&gt;
 y    0x1fe 0x00f38d&lt;br /&gt;
 y    0x1ff 0x00ffff&lt;br /&gt;
 y    0x200 0x123456&lt;br /&gt;
 y    0x201 0x123456&lt;br /&gt;
 y    0x202 0x123456&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Because the FO fifo can hold 1024 16-bit words, what we have here is a complete half-fifo.  The PCI card is likely blocking, waiting for the FIFO to be half-full again so it can empty it efficiently.  It is at this point that we suspect that the packet size might be the problem.&lt;br /&gt;
&lt;br /&gt;
Our RC1, 41-row frame should have size 372 DWORDS = 1488 bytes.  We check that this is what the DSP expects (QT_FRAME_SIZE):&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pciread x 0x3d&lt;br /&gt;
 0x5d0&lt;br /&gt;
That's 372.  Good.  Compare with the size of the most recent packet (PACKET_SIZE):&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pciread x 0x2b&lt;br /&gt;
 0x54c&lt;br /&gt;
Thats 1356 DWORDS = 5424 bytes!  That's the size of a full (4-RC, 41 row) frame.&lt;br /&gt;
&lt;br /&gt;
However, the DSP has only buffered 0x200 * 2 = 1024 bytes before stalling.  Therefore it appears that the MCE is reporting a 5424 byte packet but then sending somewhere between 1024 and 2047 bytes of data.&lt;/div&gt;</summary>
		<author><name>24.82.145.130</name></author>
		
	</entry>
	<entry>
		<id>https://cmbr.phas.ubc.ca/mcewiki/index.php?title=PCI_card_hacking&amp;diff=2526</id>
		<title>PCI card hacking</title>
		<link rel="alternate" type="text/html" href="https://cmbr.phas.ubc.ca/mcewiki/index.php?title=PCI_card_hacking&amp;diff=2526"/>
		<updated>2009-01-14T03:50:10Z</updated>

		<summary type="html">&lt;p&gt;24.82.145.130: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes using dsp_cmd and mce_cmd to debug MCE/PCI card communication issues.  These instructions can be used to resolve questions like &amp;quot;is the data getting dropped by the PCI card, or does it never arrive at the PCI card?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== RAM areas on the DSP ==&lt;br /&gt;
&lt;br /&gt;
The DSP has 3 RAM banks, known as X, Y, and P.  User data is in X and Y, while the program code is in P.  By default, all three banks contain something like 2k x 16bits.  On our hardware, however, the Y bank has been extended with an external SRAM to 8M x 16bits.&lt;br /&gt;
&lt;br /&gt;
In our firmware, X memory is used to store ordinary variables while Y memory is used for large buffers.&lt;br /&gt;
&lt;br /&gt;
== Reading and writing DSP RAM with dsp_cmd ==&lt;br /&gt;
&lt;br /&gt;
We can use dsp_cmd to read back the values of variables and buffers in the PCI card RAM.  This is done as follows:&lt;br /&gt;
 mhasse@mce-ubc-2:~$ dsp_cmd -x read X 0&lt;br /&gt;
 This is dsp_cmd version MAS/slotpc/327&lt;br /&gt;
 Line   0 : ok : X[0] = 0x208&lt;br /&gt;
&lt;br /&gt;
We can also write.  Don't write to X or P memory unless you really know what you're doing.&lt;br /&gt;
 mhasse@mce-ubc-2:~$ dsp_cmd -x write Y 0 0x1234&lt;br /&gt;
 This is dsp_cmd version MAS/slotpc/327&lt;br /&gt;
 Line   0 : ok&lt;br /&gt;
&lt;br /&gt;
It is convenient to define a few functions to make this hacking easier (you can just dump this into your bash session, or put it in a file and run &amp;quot;source file&amp;quot; whenever you want the functions to be available): &lt;br /&gt;
 function pciread {&lt;br /&gt;
     dsp_cmd -qpx read $1 $2 | cut -d' ' -f5&lt;br /&gt;
 }&lt;br /&gt;
 function pciwrite {&lt;br /&gt;
     dsp_cmd -qpx write $1 $2 $3&lt;br /&gt;
 }&lt;br /&gt;
 function pcidump {&lt;br /&gt;
     # usage: pcidump &amp;lt;BANK&amp;gt; &amp;lt;START&amp;gt; &amp;lt;COUNT&amp;gt;&lt;br /&gt;
     for i in `seq -f '%9.0f' $2 $(( $2 + $3 - 1 ))`; do printf &amp;quot;%s %#8x 0x%06x\n&amp;quot; $1 $i `pciread $1 $i`; done&lt;br /&gt;
 }&lt;br /&gt;
 function pciwash {&lt;br /&gt;
     # usage: pciwash &amp;lt;BANK&amp;gt; &amp;lt;START&amp;gt; &amp;lt;COUNT&amp;gt; &amp;lt;VALUE&amp;gt;&lt;br /&gt;
     for i in `seq -f '%9.0f' $2 $(( $2 + $3 - 1 ))`; do pciwrite $1 $i $4; done&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Then you use them like this:&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pciread x 0&lt;br /&gt;
 0x208&lt;br /&gt;
 mhasse@mce-ubc-2:~ pciwrite y 0 0x1234&lt;br /&gt;
 &lt;br /&gt;
 mhasse@mce-ubc-2:~$ pcidump Y 0x100000 4&lt;br /&gt;
 Y 0x100000 0x004f4b&lt;br /&gt;
 Y 0x100001 0x00474f&lt;br /&gt;
 Y 0x100002 0x000016&lt;br /&gt;
 Y 0x100003 0x000003&lt;br /&gt;
&lt;br /&gt;
== MCE command, reply and data buffers ==&lt;br /&gt;
&lt;br /&gt;
We can inspect the DSP's buffers if we know their addresses.  This depends on DSP code firmware revision.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; width=400&lt;br /&gt;
! Version !! Data !! Reply    !! Command&lt;br /&gt;
|-&lt;br /&gt;
| U0104 and earlier   ||    0 ||        0 ||    0x200&lt;br /&gt;
|-&lt;br /&gt;
| U0105   ||    0 || 0x100000 || 0x200000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Note about data and reply packets!*: the preamble, packet type, and frame size are stripped off.  These will not appear in the buffers in Y memory.  They are available at special locations in X memory, however.&lt;br /&gt;
&lt;br /&gt;
(Incidentally, the collision between the &amp;quot;data&amp;quot; and reply/command buffers is why U0104 and earlier cannot be used to issue STOP or other MCE commands during frame acquisition.)&lt;br /&gt;
&lt;br /&gt;
== DSP internal variables ==&lt;br /&gt;
&lt;br /&gt;
There are a few DSP internal variables, stored in X memory, that are of use in comm. hacking:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Name                 !! Address(U0104) !! Address(U0105) !! Description&lt;br /&gt;
|-&lt;br /&gt;
| STATUS               || 0x00            || 0x00          || Status (and modes) of DSP, see bit break-down below&lt;br /&gt;
|-&lt;br /&gt;
| MODE                 || n/a             || 0x01          || Flags configuring certain modes of the DSP&lt;br /&gt;
|-&lt;br /&gt;
| HEAD_W3_0            || 0x21            || 0x14          || Type of last reply or data packet, 'DA' or 'RP' &lt;br /&gt;
|-&lt;br /&gt;
| PACKET_SIZE_LOW      || 0x23            || n/a           || Size of latest reply or data packet, in 16 bit words&lt;br /&gt;
|-&lt;br /&gt;
| PACKET_SIZE          || n/a             || 0x2B          || Size of latest reply or data packet, in 32 bit words&lt;br /&gt;
|-&lt;br /&gt;
| QT_FRAME_SIZE        || 0x53            || 0x3D          || The expected size of data packets in bytes&lt;br /&gt;
|-&lt;br /&gt;
| FRAME_COUNT          || 0x01            || 0x02          || Number of DA packets received from the MCE (including discards) &lt;br /&gt;
|-&lt;br /&gt;
| QT_DROPS             || 0x5A            || 0x44          || Number of data packets dropped due to full PC RAM buffer  &lt;br /&gt;
|-&lt;br /&gt;
| RP_DROPS             || n/a             || 0x48          || Number of reply packets dropped due to PC RAM buffer unavailable (quiet_RP mode only)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Currently, the number of packets that are dropped due to a packet size mismatch between PACKET_SIZE and QT_FRAME_SIZE is not recorded explicitly.  However, such packets will cause FRAME_COUNT to increment.&lt;br /&gt;
&lt;br /&gt;
All of the above variables, except STATUS, MODE, and FRAME_COUNT are cleared by a DSP_RESET.  You can zero the frame count manually using pciwrite.&lt;br /&gt;
&lt;br /&gt;
(Incidentally, the addresses in the table above are determined from the .lod symbol table of the assembler output.)&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Firmware version U0105 is assumed below.  Use the functions defined above.&lt;br /&gt;
&lt;br /&gt;
=== Inspect a command packet ===&lt;br /&gt;
&lt;br /&gt;
Note that in current firmware, packets are copied into the DSP buffer *at the same time* as they are transmitted to the MCE.  So if your data appears in the DSP buffer, it has also been sent out on the FO transmitter.&lt;br /&gt;
&lt;br /&gt;
We issue&lt;br /&gt;
 mhasse@mce-ubc-2:~$ mce_cmd -x &amp;quot;wb cc led 7&amp;quot;&lt;br /&gt;
and then inspect the packet in the DSP buffer:&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pcidump y 0x200000 128&lt;br /&gt;
 y 0x200000 0x00a5a5&lt;br /&gt;
 y 0x200001 0x00a5a5&lt;br /&gt;
 y 0x200002 0x005a5a&lt;br /&gt;
 y 0x200003 0x005a5a&lt;br /&gt;
 y 0x200004 0x002020&lt;br /&gt;
 y 0x200005 0x005742&lt;br /&gt;
 y 0x200006 0x000002&lt;br /&gt;
 y 0x200007 0x000099&lt;br /&gt;
 y 0x200008 0x000000&lt;br /&gt;
 y 0x200009 0x000001&lt;br /&gt;
 y 0x20000a 0x000000&lt;br /&gt;
 y 0x20000b 0x000007&lt;br /&gt;
 y 0x20000c 0x000000&lt;br /&gt;
 y 0x20000d 0x000000&lt;br /&gt;
 ...&lt;br /&gt;
 y 0x20007c 0x000000&lt;br /&gt;
 y 0x20007d 0x000000&lt;br /&gt;
 y 0x20007e 0x002022&lt;br /&gt;
 y 0x20007f 0x0057dd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Is the MCE returning data? ===&lt;br /&gt;
&lt;br /&gt;
Suppose &amp;quot;mce_run&amp;quot; is blocking without data and we want to check the frame data.  We first fill the data buffer with a signature we can recognize:&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pciwash y 0x0 4096 0x123456&lt;br /&gt;
&lt;br /&gt;
and we may as well zero the frame counter, too.&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pciwrite x 0x2 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then we trigger a go somehow.  mce_run is easiest.&lt;br /&gt;
 mhasse@mce-ubc-2:~$ mce_run test_1935 1 1&lt;br /&gt;
 RUNFILE_NAME=/data/cryo/current_data//test_1935.run&lt;br /&gt;
 FRAME_BASENAME=/data/cryo/current_data//test_1935&lt;br /&gt;
&lt;br /&gt;
This hangs, so we Ctrl-C it.&lt;br /&gt;
&lt;br /&gt;
We confirm that the DSP received a single frame from the MCE:&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pciread x 2&lt;br /&gt;
 0x1&lt;br /&gt;
&lt;br /&gt;
Now inspect the data buffer:&lt;br /&gt;
 pcidump y 0x0 4096 &amp;gt; dump.txt&lt;br /&gt;
(This can take a while.) Inspecting the output we see reasonable data up to address 0x200:&lt;br /&gt;
 ...&lt;br /&gt;
 y    0x1fd 0x00ffff&lt;br /&gt;
 y    0x1fe 0x00f38d&lt;br /&gt;
 y    0x1ff 0x00ffff&lt;br /&gt;
 y    0x200 0x123456&lt;br /&gt;
 y    0x201 0x123456&lt;br /&gt;
 y    0x202 0x123456&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Because the FO fifo can hold 1024 16-bit words, what we have here is a complete half-fifo.  The PCI card is likely blocking, waiting for the FIFO to be half-full again so it can empty it efficiently.  It is at this point that we suspect that the packet size might be the problem.&lt;br /&gt;
&lt;br /&gt;
Our RC1, 41-row frame should have size 372 DWORDS = 1488 bytes.  We check that this is what the DSP expects (QT_FRAME_SIZE):&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pciread x 0x3d&lt;br /&gt;
 0x5d0&lt;br /&gt;
That's 372.  Good.  Compare with the size of the most recent packet (PACKET_SIZE):&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pciread x 0x2b&lt;br /&gt;
 0x54c&lt;br /&gt;
Thats 1356 DWORDS = 5424 bytes!  That's the size of a full (4-RC, 41 row) frame.&lt;br /&gt;
&lt;br /&gt;
However, the DSP has only buffered 0x200 * 2 = 1024 bytes before stalling.  Therefore it appears that the MCE is reporting a 5424 byte packet but then sending somewhere between 1024 and 2047 bytes of data.&lt;/div&gt;</summary>
		<author><name>24.82.145.130</name></author>
		
	</entry>
	<entry>
		<id>https://cmbr.phas.ubc.ca/mcewiki/index.php?title=PCI_card_hacking&amp;diff=2525</id>
		<title>PCI card hacking</title>
		<link rel="alternate" type="text/html" href="https://cmbr.phas.ubc.ca/mcewiki/index.php?title=PCI_card_hacking&amp;diff=2525"/>
		<updated>2009-01-14T03:23:23Z</updated>

		<summary type="html">&lt;p&gt;24.82.145.130: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes using dsp_cmd and mce_cmd to debug MCE/PCI card communication issues.  These instructions can be used to resolve questions like &amp;quot;is the data getting dropped by the PCI card, or does it never arrive at the PCI card?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== RAM areas on the DSP ==&lt;br /&gt;
&lt;br /&gt;
The DSP has 3 RAM banks, known as X, Y, and P.  User data is in X and Y, while the program code is in P.  By default, all three banks contain something like 2k x 16bits.  On our hardware, however, the Y bank has been extended with an external SRAM to 8M x 16bits.&lt;br /&gt;
&lt;br /&gt;
In our firmware, X memory is used to store ordinary variables while Y memory is used for large buffers.&lt;br /&gt;
&lt;br /&gt;
== Reading and writing DSP RAM with dsp_cmd ==&lt;br /&gt;
&lt;br /&gt;
We can use dsp_cmd to read back the values of variables and buffers in the PCI card RAM.  This is done as follows:&lt;br /&gt;
 mhasse@mce-ubc-2:~$ dsp_cmd -x read X 0&lt;br /&gt;
 This is dsp_cmd version MAS/slotpc/327&lt;br /&gt;
 Line   0 : ok : X[0] = 0x208&lt;br /&gt;
&lt;br /&gt;
We can also write.  Don't write to X or P memory unless you really know what you're doing.&lt;br /&gt;
 mhasse@mce-ubc-2:~$ dsp_cmd -x write Y 0 0x1234&lt;br /&gt;
 This is dsp_cmd version MAS/slotpc/327&lt;br /&gt;
 Line   0 : ok&lt;br /&gt;
&lt;br /&gt;
It is convenient to define a few functions to make this hacking easier (you can just dump this into your bash session, or put it in a file and run &amp;quot;source file&amp;quot; whenever you want the functions to be available): &lt;br /&gt;
 function pciread {&lt;br /&gt;
     dsp_cmd -qpx read $1 $2 | cut -d' ' -f5&lt;br /&gt;
 }&lt;br /&gt;
 function pciwrite {&lt;br /&gt;
     dsp_cmd -qpx write $1 $2 $3&lt;br /&gt;
 }&lt;br /&gt;
 function pcidump {&lt;br /&gt;
     # usage: pcidump &amp;lt;BANK&amp;gt; &amp;lt;START&amp;gt; &amp;lt;COUNT&amp;gt;&lt;br /&gt;
     for i in `seq -f '%9.0f' $2 $(( $2 + $3 - 1 ))`; do printf &amp;quot;%s %#8x 0x%06x\n&amp;quot; $1 $i `pciread $1 $i`; done&lt;br /&gt;
 }&lt;br /&gt;
 function pciwash {&lt;br /&gt;
     # usage: pciwash &amp;lt;BANK&amp;gt; &amp;lt;START&amp;gt; &amp;lt;COUNT&amp;gt; &amp;lt;VALUE&amp;gt;&lt;br /&gt;
     for i in `seq -f '%9.0f' $2 $(( $2 + $3 - 1 ))`; do pciwrite $1 $i $4; done&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Then you use them like this:&lt;br /&gt;
 mhasse@mce-ubc-2:~$ pciread x 0&lt;br /&gt;
 0x208&lt;br /&gt;
 mhasse@mce-ubc-2:~ pciwrite y 0 0x1234&lt;br /&gt;
 &lt;br /&gt;
 mhasse@mce-ubc-2:~$ pcidump Y 0x100000 4&lt;br /&gt;
 Y 0x100000 0x004f4b&lt;br /&gt;
 Y 0x100001 0x00474f&lt;br /&gt;
 Y 0x100002 0x000016&lt;br /&gt;
 Y 0x100003 0x000003&lt;br /&gt;
&lt;br /&gt;
== MCE command, reply and data buffers ==&lt;br /&gt;
&lt;br /&gt;
We can inspect the DSP's buffers if we know their addresses.  This depends on DSP code firmware revision.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; width=400&lt;br /&gt;
! Version !! Data !! Reply    !! Command&lt;br /&gt;
|-&lt;br /&gt;
| U0104 and earlier   ||    0 ||        0 ||    0x200&lt;br /&gt;
|-&lt;br /&gt;
| U0105   ||    0 || 0x100000 || 0x200000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Note about data and reply packets!*: the preamble, packet type, and frame size are stripped off.  These will not appear in the buffers in Y memory.  They are available at special locations in X memory, however.&lt;br /&gt;
&lt;br /&gt;
(Incidentally, the collision between the &amp;quot;data&amp;quot; and reply/command buffers is why U0104 and earlier cannot be used to issue STOP or other MCE commands during frame acquisition.)&lt;br /&gt;
&lt;br /&gt;
== DSP internal variables ==&lt;br /&gt;
&lt;br /&gt;
There are a few DSP internal variables, stored in X memory, that are of use in comm. hacking:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Name                 !! Address(U0104) !! Address(U0105) !! Description&lt;br /&gt;
|-&lt;br /&gt;
| STATUS               || 0x00            || 0x00          || Status (and modes) of DSP, see bit break-down below&lt;br /&gt;
|-&lt;br /&gt;
| MODE                 || n/a             || 0x01          || Flags configuring certain modes of the DSP&lt;br /&gt;
|-&lt;br /&gt;
| HEAD_W3_0            || 0x21            || 0x14          || Type of last reply or data packet, 'DA' or 'RP' &lt;br /&gt;
|-&lt;br /&gt;
| PACKET_SIZE_LOW      || 0x23            || n/a           || Size of latest reply or data packet, in 16 bit words&lt;br /&gt;
|-&lt;br /&gt;
| PACKET_SIZE          || n/a             || 0x2B          || Size of latest reply or data packet, in 32 bit words&lt;br /&gt;
|-&lt;br /&gt;
| QT_FRAME_SIZE        || 0x53            || 0x3D          || The expected size of data packets in bytes&lt;br /&gt;
|-&lt;br /&gt;
| FRAME_COUNT          || 0x01            || 0x02          || Number of DA packets received from the MCE (including discards) &lt;br /&gt;
|-&lt;br /&gt;
| QT_DROPS             || 0x5A            || 0x44          || Number of data packets dropped due to full PC RAM buffer  &lt;br /&gt;
|-&lt;br /&gt;
| RP_DROPS             || n/a             || 0x48          || Number of reply packets dropped due to PC RAM buffer unavailable (quiet_RP mode only)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Currently, the number of packets that are dropped due to a packet size mismatch between PACKET_SIZE and QT_FRAME_SIZE is not recorded explicitly.  However, such packets will cause FRAME_COUNT to increment.&lt;br /&gt;
&lt;br /&gt;
All of the above variables, except STATUS, MODE, and FRAME_COUNT are cleared by a DSP_RESET.  You can zero the frame count manually using pciwrite.&lt;br /&gt;
&lt;br /&gt;
(Incidentally, the addresses in the table above are determined from the .lod symbol table of the assembler output.)&lt;/div&gt;</summary>
		<author><name>24.82.145.130</name></author>
		
	</entry>
</feed>