ΣSigmaStudio Ask AI Русский Log in

how to understand a example of tigersharc 201 dsp (visual dsp++5.0)?

Processors & DSP shedmaze Dec 20, 2012 00:00 5 replies Original on forum ↗
Subscribe
shedmaze Question
Dec 20, 2012 00:00

hello,

right now i am learning the tigersharc dsp by myself, and i have bought a tigher sharc EZ-kit lite board, totally i has bought 3 boards.

i read an example in the following path: \VisualDSP 5.0\TS\Examples\ADSP-TS201 EZ-KIT Lite\Power_On_Self_Test

in this project, it has a file audio_test.c, and in this file, the following codes confused me, can you help me?? thank you and thank you.

void audio_int( void )
{
int iChannelX_Left;
int iChannelX_Right;
float fChannelX;

iChannelX_Left = ReadDataLeft;
iChannelX_Right = ReadDataRight;

// shift 24-bit codec data left channel
iChannelX_Left <<= 8;
iChannelX_Left >>= 8; // what has it done?? i don't know. it seems there is no change for the iChannelX_Left

// sign extend values
if( iChannelX_Left & 0x800000 )
{
iChannelX_Left |= 0xFF000000; // this part is also, i don't know what are they doing ...?
}

// shift 24-bit codec data right channel
iChannelX_Right <<= 8;
iChannelX_Right >>= 8;

// sign extend values
if( iChannelX_Right & 0x800000 )
{
iChannelX_Right |= 0xFF000000;
}

ts201

power_on_self_test

example

ADIApproved Reply
Dec 20, 2012 00:00

Hi,

The first instructions perform a bitwise left shift assignment, followed by a bitwise right shift assignment. The aim here is to clear the most significant 8 bits of the data (as the int holds 32-bits, but the codec data is 24-bit).

Then, the code checks whether the sign-bit of this 24-bit value is set (to indicate a negative value). So, a bitwise AND is done with hex value 0x800000 - in binary 10000000 00000000 00000000. If bit 23 (the sign bit of the 240bit value) is set, the number should be negative, so the sign bit in the 32-bit integer that holds the value needs to be set by OR-ing the value with 0xFF000000 (this actually sets all of the Most-Significant 8 bits to 1).

Hope that clarifies the purpose of that particular section: basically, clearing the 8 most significant bits, the setting the sign bit based on bit 23 of the 24-bit codec data.

Regards,
Craig.

shedmaze Reply
Dec 20, 2012 00:00

hello, Craig,

thanks for your so quickly replying... right now, i am in Korean, the time is 3:55AM, i am still writing a report.

anyway, tomorrow is a holiday~~

for the first question, i am still confused, the ReadDataLeft is a 'long' integer, so it is already 64bits, then it was given to the iChannelX_Left, i think it is not necessary to use the shift moving,can you give me a example for that.

for the dsp communication with the equipment, i can't do it very well. so please be patient.

shedmaze Reply
Dec 20, 2012 00:00

hello,

the example means that can you explain the process of the following codes, thanks.

// shift 24-bit codec data left channel

iChannelX_Left <<= 8;

iChannelX_Left >>= 8;

best wishes,

SHENG MING

ADIApproved Reply
Dec 21, 2012 00:00

Hi,

While ReadDataLeft is a 64-bit long, iChannelX_Left is a 32-bit int. The data coming from the Codec is only 24-bits, so there are still 8 bits of 'garbage' in the 8 most significant bits that need to be removed before iChannelX_Left is processed.

For example, if the data coming in is 0x22222222, the left/right shift would set it to 0x00222222. There may, for example, be a value where bit 31 is set - indicating a negative number, while bit 23 is NOT set because the value from the codec was not negative. This needs to be shifted out and corrected.

Regards,

Craig.

EZAdministrator Reply
Aug 2, 2018 00:00

This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.

Thank you,
EZ Admin