Looking at how to read the Switches

This is for an Analog Devices Sharc processor

A bank of switches is used to configure the stereo generator at startup and this is the first thing the DSP has to do when coming out of lethargy, read the switches and fill the working arrays with the correct data.

Decoding the Switch Settings

A single memory read at address swt reads 32 bits of which 16 bits are active. the variable swtchs is stored for detection of changes to the state.

unsigned int    swtchs;
unsigned int	program;
unsigned int 	i;
//	Read the switch bank at memory bank
    swtchs = (*(&swt) & 0x0000FFFF);
    program = swtchs & 0x3;
//	load pre-emphasis parameters
    switch (program)
    {
        case PRE_EMPHASIS50US:
            for(i=0;i<10;i++)fintXus[i] = fint50uS[i];
            break;
        case PRE_EMPHASIS75US:
            for(i=0;i<10;i++)fintXuS[i]=fint75uS[i];
            break;
        case PRE_EMPHASIS125US:
            for(i=0;i<10;i++)fintXuS[i]=fint125uS[i];
            break;
        default:
//	0uS pre-emphasis
            for(i=0;i<10;i++)fintXuS[i]=fint0uS[
            break;
    }

Bit mapping is used to extract the bits of each parameter. Here bits 0, 1 are extracted to determine the pre-emphasis to be used. A case comparision is used to select the correct set of pre-emphasis parameters. The parameters are loaded into the array fintXuS that is used by the processing loop.

All the other parameters are extracted in the same way.