AnsweredAssumed Answered

DSP / Sigma Studio

Question asked by nb123456 on Jan 22, 2017
Latest reply on Feb 27, 2017 by KJBob

Hi, 

 

I want to know how can I remember variables across samples calculation in the DSP processing?

That means I want to have 3 variables that I use each time I calculate the output for a given output:

 

# Global variables to remember

PHASE, omega

function calcOutput(sample) {

    PHASE      = PHASE + (omega * 0.0000104)

    lastError = sample - cos(PHASE)

   gradPhase =  -2.0 * (lastError) * sin(PHASE)
   PHASE = PHASE + phaseShift

   gradTimePhase = (gradPhase)/0.0000104

   omega = omega + gradTimePhase
   return cos (PHASE) # That's the output

}

 

That's a very simple function (very quick) that need to use two variables that are being saved across samples. What is the way to do it? (since I don't see the option to write custom code in the ADAU1701 processor I bought)

Outcomes