Post Go back to editing

SC589 mini ADAU1761 initialization / sampling set / PLL

Category: Software
Product Number: ADZS-SC589-mini Rev. 2.1
Software Version: SHARC Bare Metal Framework 2.1.2 / Cross Core Embedded 2.11.1

Basic setup:  ADZS SC589 mini Board Rev. 2.1, Cross Core Embedded 2.11.1 SHARC bare Metal Framework template project, without the Audio Project Fin setting, no FAUST, and SHARC core 1 in use only.

The audio block size is 32, the sample rate is 48kHz.  The project has been run in a Debug configuration using the ICE 1000 emulator.

Problem:  The audio framework does not successfully initialize due to the ADAU 1761 codec not initializing correctly (as far as I can tell).

During the ARM core startup process, and audio framework initialization, the ADAU1761 codec is initialized.  The function in question is:

bool adau1761_set_samplerate(BM_ADAU_DEVICE *adau1761,
uint32_t sample_rate)

This function implementation is in the bm_adau_driver.c source file.

The specific block of code (below) is where the PLL is set and verified.  The while loop used to find the PLL locked bit goes into an infinite loop, and the entire program

obviously hangs.

// 3. wait for PLL to lock
uint8_t addr[2], result[6], value = 0;
addr[0] = ADAU1761_REG_PLL_CONTROL_0 >> 8;
addr[1] = ADAU1761_REG_PLL_CONTROL_0 & 0xff;

while ((value & 0x2) == 0) {
twi_write_block_r(&adau1761->twi, addr, 2, true);
twi_read_block(&adau1761->twi, result, 6);
value = result[5];
}

Question:  Why doesn't the PLL lock?  I have successfully run the SAM audio starter, and the ADAU1761 codec seems to work fine.  I am just not sure where the template SHARC bare metal framework is

missing some configuration files or if there is something wrong in the project setup.  The logging is fine, and I have been able to pinpoint this area of code as an issue.  I have thought about using the SAM audio starter project as a model for getting this to work, but I

was hoping that someone had a quick fix. 

Any help would be appreciated!

Regards,

Chris



Type errors
[edited by: chlander73 at 6:48 PM (GMT -4) on 9 Sep 2023]
Parents
  • Update:

    After looking over the SAM audio start adau1761 code, i found that there should be a 0-10 second wait for the PLL to lock.  Other sources on the web for Linux implementations recommended the same.  With some additional changes, I was able to get the default SHARC core 1 loopback audio processing working.  The volume is very low, so turn up your input source and the amplifier receiving the output from the SC589 / ADAU1761.  I have yet to mess with the gain settings.

    I modified the while loop as follows:

    uint16_t timeout = 10000;

    log_event(EVENT_INFO, "Attempting PLL lock");

    while (timeout-- && ((value & 0x2) == 0)) {

        twi_read_block(&adau1761->twi, result, 6);
        value = result[5];
    }

    if (timeout == 0) {
        log_event(EVENT_FATAL, "PLL would not lock before 10 sec timeout");
    } else {
       log_event(EVENT_INFO, "PLL lock success!");
    }

    Additionally, I took the exported SigmaAudio parameter files from the SAM audio starter project and replaced those at these paths:

    drivers/bm_adau_driver/configurations/ss_schematics/ADAU1761_ADAU1761_8ch_i2s_master/Exported_init_files/NumBytes_ADAU1761.dat

    drivers/bm_adau_driver/configurations/ss_schematics/ADAU1761_ADAU1761_8ch_i2s_master/Exported_init_files/TxBuffer_ADAU1761.dat

    A verification block of code was an issue, so I commented that out (this is just after the sampling setting / PLL lock).

    // Confirm that the ADAU1761 is running (a good indication that it has been initialized properly)
    //uint8_t sigmadspRunning;
    //adau_read_ctrl_reg(&adau1761_local, ADAU1761_REG_DSP_RUN, &sigmadspRunning);
    //if (!(sigmadspRunning & 0x1)) {
    // log_event(EVENT_FATAL, " The SigmaDSP core inside the ADAU1761 is not running");
    //}

    Also, if you are not using the Audio Project Fin, comment out the gain settings:

    // Set the AUX channel gain depending on whether a Audio Project Fin is present, and which version of the board
    //uint8_t currentRegVal;
    // Left channel AUX gain
    //adau_read_ctrl_reg(&adau1761_local, ADAU1761_REG_REC_MIXER_LEFT_1, &currentRegVal);
    //currentRegVal &= 0xF8;
    //currentRegVal |= auxGain;
    //adau_write_ctrl_reg(&adau1761_local, ADAU1761_REG_REC_MIXER_LEFT_1, currentRegVal);

    // Right channel AUX gain
    //adau_read_ctrl_reg(&adau1761_local, ADAU1761_REG_REC_MIXER_RIGHT_1, &currentRegVal);
    //currentRegVal &= 0xF8;
    //currentRegVal |= auxGain;
    //adau_write_ctrl_reg(&adau1761_local, ADAU1761_REG_REC_MIXER_RIGHT_1, currentRegVal);

    Update (9/10):

    The DMA's in the SHARC cores are not enabling.  So, the audio observation was not observed from within audio processing blocks.  This is likely just the codec's own loopback.

    Still working to have the audio processing part work. 

    Update (9/10) - 2:

    DMAs enable with a while / timeout, but audio is still not being processed as expected.  The audio buffers in the processing block do not appear to be connected to anything, where the ADUA1761 is concerned.  I may raise a new question for this specific issue.  Or, it may be that I need to wait on a new framework revision.

Reply
  • Update:

    After looking over the SAM audio start adau1761 code, i found that there should be a 0-10 second wait for the PLL to lock.  Other sources on the web for Linux implementations recommended the same.  With some additional changes, I was able to get the default SHARC core 1 loopback audio processing working.  The volume is very low, so turn up your input source and the amplifier receiving the output from the SC589 / ADAU1761.  I have yet to mess with the gain settings.

    I modified the while loop as follows:

    uint16_t timeout = 10000;

    log_event(EVENT_INFO, "Attempting PLL lock");

    while (timeout-- && ((value & 0x2) == 0)) {

        twi_read_block(&adau1761->twi, result, 6);
        value = result[5];
    }

    if (timeout == 0) {
        log_event(EVENT_FATAL, "PLL would not lock before 10 sec timeout");
    } else {
       log_event(EVENT_INFO, "PLL lock success!");
    }

    Additionally, I took the exported SigmaAudio parameter files from the SAM audio starter project and replaced those at these paths:

    drivers/bm_adau_driver/configurations/ss_schematics/ADAU1761_ADAU1761_8ch_i2s_master/Exported_init_files/NumBytes_ADAU1761.dat

    drivers/bm_adau_driver/configurations/ss_schematics/ADAU1761_ADAU1761_8ch_i2s_master/Exported_init_files/TxBuffer_ADAU1761.dat

    A verification block of code was an issue, so I commented that out (this is just after the sampling setting / PLL lock).

    // Confirm that the ADAU1761 is running (a good indication that it has been initialized properly)
    //uint8_t sigmadspRunning;
    //adau_read_ctrl_reg(&adau1761_local, ADAU1761_REG_DSP_RUN, &sigmadspRunning);
    //if (!(sigmadspRunning & 0x1)) {
    // log_event(EVENT_FATAL, " The SigmaDSP core inside the ADAU1761 is not running");
    //}

    Also, if you are not using the Audio Project Fin, comment out the gain settings:

    // Set the AUX channel gain depending on whether a Audio Project Fin is present, and which version of the board
    //uint8_t currentRegVal;
    // Left channel AUX gain
    //adau_read_ctrl_reg(&adau1761_local, ADAU1761_REG_REC_MIXER_LEFT_1, &currentRegVal);
    //currentRegVal &= 0xF8;
    //currentRegVal |= auxGain;
    //adau_write_ctrl_reg(&adau1761_local, ADAU1761_REG_REC_MIXER_LEFT_1, currentRegVal);

    // Right channel AUX gain
    //adau_read_ctrl_reg(&adau1761_local, ADAU1761_REG_REC_MIXER_RIGHT_1, &currentRegVal);
    //currentRegVal &= 0xF8;
    //currentRegVal |= auxGain;
    //adau_write_ctrl_reg(&adau1761_local, ADAU1761_REG_REC_MIXER_RIGHT_1, currentRegVal);

    Update (9/10):

    The DMA's in the SHARC cores are not enabling.  So, the audio observation was not observed from within audio processing blocks.  This is likely just the codec's own loopback.

    Still working to have the audio processing part work. 

    Update (9/10) - 2:

    DMAs enable with a while / timeout, but audio is still not being processed as expected.  The audio buffers in the processing block do not appear to be connected to anything, where the ADUA1761 is concerned.  I may raise a new question for this specific issue.  Or, it may be that I need to wait on a new framework revision.

Children
No Data