Post Go back to editing

trying to access global variable in algorithm designer code

Thread Summary

The user is trying to use global variables of type float and a custom structure in the Configure buffer sizes tab of Sigma Studio+ with the SC573. The issue arises when writing to the 'current_gain' variable in the INIT_GainTest function, causing the algorithm to break. The final answer suggests using the debugging technique for custom plug-ins in SigmaStudio for SHARC to identify the problem.
AI Generated Content
Category: Software
Product Number: sigma studio+
Software Version: Sigma Studio+ 2.4.0

Hi,

I'm trying to figure out the how to correctly use the Configure buffer sizes tab in the algorithm designer section of Sigma Studio+ using SC573.

I understand and make work the examples of the mute no slew and gain control and even the BPROCESS_ and INIT_ functionality.

My problem is I want to declare some global variables of type float and also my own structure but I cannot get the algorithm to work. I think it maybe something to do with I haven't configured the buffer sizes correctly.
I have read the memory types in the coding conventions

wiki.analog.com/.../algorithm_designer_coding_conventions

and refer to this for how to use global variables but I don't understand how to apply this for the global variables I have. Which one of the memory types do I use ?
State, State B, State C, State (Ext Pre), Scratch(PM), Scratch(DM)

Constant Tables

All global variables and global tables in the Module are treated as constant tables by SigmaStudio. In case of ADSP-SC5xx only one instance of this memory is allocated per schematic. This memory is mapped on to the parameter buffer. Note: Modification of this memory is allowed even though this is treated as constant table by SigmaStudio. This memory is shared across all modules in any given schematic.


in my source code (below )everything builds and works as long as I don't try and write to the variable
'current_gain' as I try in INIT_GainTest

any suggestions why writing to the variable breaks ?

Many thanks

here is my source code

#include "adi_ss_extmod.h"

float current_gain = 2;


#pragma section("seg_pmco")
void BPROCESS_GainTest (SSBlockAlgo* pBlkAlgoInfo)
{
int index, sample, gain, blockSize, repCount;
float *pInput, *pOutput;

repCount = pBlkAlgoInfo->nGrowth;

for(index = 0; index < repCount; index++)
{
blockSize = pBlkAlgoInfo->pInputs[index].pBlockProperties->nBlockSize;
gain = ((float *)pBlkAlgoInfo->pParam)[index];

pInput = pBlkAlgoInfo->pInputs[index].pSamples;
pOutput = pBlkAlgoInfo->pOutputs[index].pSamples;

for(sample = 0; sample < blockSize; sample++)
{
pOutput[sample] = pInput[sample] * gain;
}
}
}

#pragma section("seg_pmco")
void INIT_GainTest (SSBlockAlgo* pBlkAlgoInfo)
{
int index, repCount;

// current_gain = 3; // if I try to write to variable then it breaks everything

repCount = pBlkAlgoInfo->nGrowth;

for(index = 0; index < repCount; index++)
{
((float *)pBlkAlgoInfo->pParam)[index] = current_gain;
}
}
Alogrithm_test.zip

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.