Datasheet

Table Of Contents
203 interp1->accum[0] = i;
204 printf("%d\t%d\n", i, (int) interp1->peek[0]);
205 }
206 }
This should print:
-1024 0
-768 0
-512 0
-256 0
0 0
256 64
512 128
768 192
1024 255
2.3.1.6.4. Sample Use Case: Linear Interpolation
Linear interpolation is a more complete example of using blend mode in conjunction with other interpolator functionality:
In this example, ACCUM0 is used to track a fixed point (integer/fraction) position within a list of values to be interpolated.
Lane 0 is used to produce an address into the value array for the integer part of the position. The fractional part of the
position is shifted to produce a value from 0-255 for the blend. The blend is performed between two consecutive values in
the array.
Finally the fractional position is updated via a single write to ACCUM0_ADD_RAW.
Pico Examples: https://github.com/raspberrypi/pico-examples/tree/pre_release/interp/hello_interp/hello_interp.c Lines 144 - 186
144 void linear_interpolation() {
145 puts("Linear interpolation:");
146 const int uv_fractional_bits = 12;
147
148 // for lane 0
149 // shift and mask XXXX XXXX XXXX XXXX XXXX FFFF FFFF FFFF (accum 0)
150 // to 0000 0000 000X XXXX XXXX XXXX XXXX XXX0
151 // i.e. non fractional part times 2 (for uint16_t)
152 interp_config cfg = interp_default_config();
153 interp_config_shift(&cfg, uv_fractional_bits - 1);
154 interp_config_mask(&cfg, 1, 32 - uv_fractional_bits);
155 interp_config_blend(&cfg, true);
156 interp_set_config(interp0, 0, &cfg);
157
158 // for lane 1
159 // shift XXXX XXXX XXXX XXXX XXXX FFFF FFFF FFFF (accum 0 via cross input)
160 // to 0000 XXXX XXXX XXXX XXXX FFFF FFFF FFFF
161
162 cfg = interp_default_config();
163 interp_config_shift(&cfg, uv_fractional_bits - 8);
164 interp_config_signed(&cfg, true);
165 interp_config_cross_input(&cfg, true); // signed blending
166 interp_set_config(interp0, 1, &cfg);
167
168 int16_t samples[] = {0, 10, -20, -1000, 500};
169
170 // step is 1/4 in our fractional representation
171 uint step = (1 << uv_fractional_bits) / 4;
RP2040 Datasheet
2.3. Processor subsystem 43