Forums

ADSP-2181 using variable between functions

Started by skottfelt 5 years ago3 replieslatest reply 5 years ago84 views

Hi all

I am using an ADSP-2181 as a sequencer for a CCD. Normal readout works perfectly well, and I can also perform a process called 'pocket pumping' (where charge is moved back and fourth between the pixels) of the serial register with a single value. However, I want to change that value for every 5 lines I read out and I cannot get that to work.

I am trying to change a the value tph in one function (main_function) and then use it in another function (delay_tph), but I find that the tph value does not change, i.e the delay time in delay_tph stays the same, or at least does not act as expected. if I set tph to a fixed value, then it does works as expected. 

Is it a syntax problem, or is it something intrinsic with how DSP works, i.e. that you cannot change a value in one function and then use that value in another function?

Thanks in advance

Simplified version of the DSP code:

.MODULE/SEG=int_pm main;
.VAR/DM/RAM tphVals [10] {list of the different values I want to use}
.INIT tphVals[0]:1,2,8,16,32,64,128,256,512,1028;
.CONST tph=0;  {the value that should be changed}

primeloop:
{some other functions}
CALL main_funtion;
JUMP primeloop

main_function:
I5=^tphVals;
L5=0;
M5=1;
CNTR=10; {setting number of tphVals}
DO tphloop UNTIL CE;
   AX0=PM(I5,M5); {selecting tph from tphVals, and increment the counter}
   DM(tph)=AX0;   {save the the value to the tph const}
   CNTR=5;  {use the same tph for 5 lines}
   DO lineloope UNTIL CE;
      CALL pump;  {run the pump seq for that line in the serial register}
      CNTR=2300;  {number of pixels in serial register}
      DO rowloope UNTIL CE;
         ... {readout serial register}
      rowloope:NOP;
   lineloope:NOP;
tphloop:NOP;
RTS;

pump_tph:
CNTR=1000; {number of pumps}
DO pumploop UNTIL CE;
   IO(CLOCKS)=MX0; {set clocks to some hex value}
   CALL delayTph; {Pixel integration time}
   IO(CLOCKS)=SR1; {change clocks}
   CALL delayTph; {Pixel integration time}
   IO(CLOCKS)=MR0; {EF1 on}
   ... etc ...
pumploop:NOP;
RTS;

delay_tph:
CNTR=DM(tph); {wait for tph value clock cycles}
DO deltph UNTIL CE;
deltph:NOP;
RTS;
[ - ]
Reply by BEBSynthesizersNovember 13, 2017

Hello,

you declare tph as a .CONST, it should be a .VAR located in DM.

Right now, your code is assembled in a way you are probably not expecting.

For example, if you write DM(tph)=R0, the assembler translates it as DM(0)=R0 and not "store R0 content in the variable located at tph address"

Change the declaration of tph to .VAR/DM/RAM tph; and this should solve your problem

Benoit

[ - ]
Reply by skottfeltNovember 16, 2017

Hi Benoit 

Thank you for your answer. I did as you suggested, i.e changing 

.CONST tph=0;

to 

.VAR/DM/RAM tph;

However this did not make any difference to the output. Can you think of any other problems with my code? Am I using the I5,L5,M5 register in the correct way?

Thanks, Jesper

[ - ]
Reply by BEBSynthesizersNovember 18, 2017

Hi Jesper,

that's rather weird. I should make a quick test here to see better what explains that. I do not work anymore on the ADSP218x (I use only SHARC and Sigma DSPs now), but I still have my compilation chain somewhere.

I will try to enter your code when I will have time and see where the problem can be (but honnestly, I can't really tell when I can do that)

Benoit