I'm testing a project on a signal processing processor (ADSP 21489). I'm using as a development software VisualDSP++ 5.0 from Analog Devices. I use the DMA buffers to send data to a CODEC.
The problem is that in Debug mode everything is fine, but in Release mode it's not working. The compiler optimizes something that shouldn't be optimized. I tried making the variables volatile and adding #pragma optimize_off, but still didn't work. Any tips how this can be resolved?
extern volatile int inputReady;
extern volatile int buffer_cntr;
static void fixData (int *output, float *input, unsigned int outstep, unsigned int length)
{
int i;
for(i = 0; i < length; i++)
{
output[outstep*i] = __builtin_conv_FtoR(input[i]);
}
}
#pragma optimize_off
volatile int sine_cnt = 0;
static void process_audioBlocks(void)
{
memcpy(fBlockA.Tx_L1, &sine[sine_cnt], DAC_NUM_SAMPLES);
memcpy(fBlockA.Tx_R1, &sine[sine_cnt], DAC_NUM_SAMPLES);
memcpy(fBlockA.Tx_L2, &sine[sine_cnt], DAC_NUM_SAMPLES);
memcpy(fBlockA.Tx_R2, &sine[sine_cnt], DAC_NUM_SAMPLES);
memcpy(fBlockA.Tx_R3, &sine[sine_cnt], DAC_NUM_SAMPLES);
memcpy(fBlockA.Tx_L3, &sine[sine_cnt], DAC_NUM_SAMPLES);
memcpy(fBlockA.Tx_L4, &sine[sine_cnt], DAC_NUM_SAMPLES);
memcpy(fBlockA.Tx_R4, &sine[sine_cnt], DAC_NUM_SAMPLES);
if (sine_cnt < ARRAY_SIZE(sine) - DAC_NUM_SAMPLES)
{
sine_cnt += DAC_NUM_SAMPLES;
}
else
{
sine_cnt = 0;
}
}
#pragma optimize_as_cmd_line
#pragma optimize_off
void AD1938_ISR(int sig_int)
{
int i;
if(isProcessing)
{
ProcessingTooLong();
}
else
{
//Increment the block pointer
buffer_cntr++;
buffer_cntr %= 2;
inputReady = 1;
}
}
#pragma optimize_as_cmd_line
#pragma optimize_off
void AD1938_Handle_Codec_Data(volatile int buffer_cntr)
{
// Clear the Block Ready Semaphore
inputReady = 0;
// Set the Processing Active Semaphore before starting processing
isProcessing = 1;
// Place the audio processing algorithm here.
process_audioBlocks();
// Fix DAC data for AD1938
fixData(tx_block_pointer[buffer_cntr]+0, fBlockA.Tx_L1, NUM_TX_SLOTS, DAC_NUM_SAMPLES);
fixData(tx_block_pointer[buffer_cntr]+1, fBlockA.Tx_R1, NUM_TX_SLOTS, DAC_NUM_SAMPLES);
fixData(tx_block_pointer[buffer_cntr]+2, fBlockA.Tx_L2, NUM_TX_SLOTS, DAC_NUM_SAMPLES);
fixData(tx_block_pointer[buffer_cntr]+3, fBlockA.Tx_R2, NUM_TX_SLOTS, DAC_NUM_SAMPLES);
fixData(tx_block_pointer[buffer_cntr]+4, fBlockA.Tx_L3, NUM_TX_SLOTS, DAC_NUM_SAMPLES);
fixData(tx_block_pointer[buffer_cntr]+5, fBlockA.Tx_R3, NUM_TX_SLOTS, DAC_NUM_SAMPLES);
fixData(tx_block_pointer[buffer_cntr]+6, fBlockA.Tx_L4, NUM_TX_SLOTS, DAC_NUM_SAMPLES);
fixData(tx_block_pointer[buffer_cntr]+7, fBlockA.Tx_R4, NUM_TX_SLOTS, DAC_NUM_SAMPLES);
// Clear the Processing Active Semaphore after processing is complete
isProcessing = 0;
}
#pragma optimize_as_cmd_line
This is part of my code. The AD1938_ISR is a interrupt handler which initiates the transfer. The tx_block_pointer contains pointers to the dma buffer (ping-pong transfer mode).