This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem changing BYPASS Mode to PLLC Mode C6455

Hi.

I need to change the Frequency of the EMIFA Port for an specific application. The idea is to send an specific frequency to an FPGA through ECLKOUT pin. I'm using the example given in the Code Composer Studio Documents for PLLC, but this example use the DSP in the BYPASS Mode. It's clear that Using BYPASS Mode you can only change the Frequency of Emifa port modifying PLLDIV4 Register. However, I need to use the PREDIV and PLLM registers to have the possibility to get more frequencies. I tried to use some lines of code to change the PLLC to PLL Mode, however those changes didn't work. It is always in the BYPASS Mode. Can you help me with that?

Thank you.

The example code is:


#include <stdio.h>
#include <csl_pllc.h>

/* PLLC module handle structure */
CSL_PllcHandle           hPllc = NULL;

/* forward declarations*/
void pllc_csl_example (void);
void pllc_error_exit (void);
/*
 *  ============================================================================
 *  @func   main
 *  ============================================================================
*/
void main (
    void
)
{
    /* Call the example routine */
    pllc_csl_example ();

}

/*
 *  ============================================================================
 *  @func   pllc_csl_example
 *  ============================================================================
*/
void pllc_csl_example (
    void
)
{
    CSL_PllcObj              pllcObj;
    CSL_Status               status;
    CSL_PllcHwSetup          hwSetup;
    CSL_PllcHwSetup          hwSetupRead;
    CSL_PllcDivideControl    arg;
    CSL_PllcDivRatio         arg1;
    CSL_BitMask32            response;  
    CSL_BitMask32            argPllCtrl;   

    /* Initialize the PLLC CSL module */
    status = CSL_pllcInit(NULL);

    if (status != CSL_SOK) {
        printf ("PLLC: Initialization... Failed.\n");
        printf ("\tReason: CSL_pllcInit failed. [status = 0x%x].\n", status);
        return;
    }

    /* Clear local data structures */
    memset(&pllcObj, 0, sizeof(CSL_PllcObj));

    /* Open the PLLC CSL module */
    hPllc = CSL_pllcOpen (&pllcObj, CSL_PLLC_1, NULL, &status);

    if ((hPllc == NULL) || (status != CSL_SOK)) {
        printf ("PLLC: Open... Failed.\n");
        printf ("\tReason: Error opening the instance. [status = 0x%x, "\
                "hPllc = 0x%x].\n", status, hPllc);
        return;
    }

    /* Setup PLLC hardware parameters */
    hwSetup.divEnable  = (CSL_BitMask32) CSL_PLLC_DIVEN_PLLDIV4 | CSL_PLLC_DIVEN_PREDIV |
                            CSL_PLLC_DIVEN_PLLDIV5;

    hwSetup.preDiv     = (Uint32)        0x00000002;
    hwSetup.pllM       = (Uint32)        0x000000015;
    hwSetup.pllDiv4    = (Uint32)        0x00000002;
    hwSetup.pllDiv5    = (Uint32)        0x00000002;

    status = CSL_pllcHwSetup (hPllc, &hwSetup);

    if (status != CSL_SOK) {
        printf ("PLLC: HwSetup... Failed.\n");
        printf ("\tReason: Error setting up the hardware."\
                " [status = 0x%x, hPllc = 0x%x].\n", status, hPllc);
        pllc_error_exit ();
        return;
    }

    /* Read back */

    status = CSL_pllcGetHwSetup (hPllc, &hwSetupRead);

    if (status != CSL_SOK) {
        printf ("PLLC: Hardware setup parameters reading... Failed.\n");
        printf ("\tReason: Error setting in hardware validation."\
                " [status = 0x%x, hPllc = 0x%x].\n", status, hPllc);
        pllc_error_exit ();

    }

    /* Change divider settings for PLLDIV4 */

    /* Wait if another GO operation is currently in progress.*/
    do {
        CSL_pllcGetHwStatus (hPllc, CSL_PLLC_QUERY_STATUS, &response);
    } while (response & CSL_PLLC_STATUS_GO);

    /* Command to enable PLLDIV4 */
    arg.divNum = CSL_PLLC_DIVSEL_PLLDIV4;
    arg.divCtrl = CSL_PLLC_PLLDIV_ENABLE;

    status = CSL_pllcHwControl (hPllc, CSL_PLLC_CMD_PLLDIV_CONTROL,
                                   &arg);
    if (status != CSL_SOK) {
        printf ("PLLC: HwControl for PLL Divider Control... Failed.\n");
        printf ("\tReason: Error in Divider Control."\
                " [status = 0x%x, hPllc = 0x%x].\n", status, hPllc);
        pllc_error_exit ();
        return;
    }

    /* Command to change PLLDIV4 Divider Ratio */
    arg1.divNum = CSL_PLLC_DIVSEL_PLLDIV4;   
    arg1.divRatio = 0x00000004;

    status = CSL_pllcHwControl (hPllc, CSL_PLLC_CMD_SET_PLLRATIO,
                                   &arg1);

    if ((status != CSL_SOK) || (status == CSL_ESYS_INVPARAMS))
    {
        printf ("PLLC: HwControl for PLL Divider Ratio Set Command "\
                "Control... Failed.\n");
        printf ("\tReason: Error in Control for Divider Ratio Set Command."\
                " [status = 0x%x, hPllc = 0x%x].\n", status, hPllc);
        pllc_error_exit ();
        return;
    }

    /* Set GOSET bit to change/set the dividers */
    argPllCtrl = 0x010000;   /* value to set the GOSET bit */
    status = CSL_pllcHwControl (hPllc, CSL_PLLC_CMD_PLLCONTROL,
                                   &argPllCtrl);
    if (status != CSL_SOK) {
        printf ("PLLC: HwControl for PLL command control... Failed.\n");
        printf ("\tReason: Error in PLL Command Control."\
                " [status = 0x%x, hPllc = 0x%x].\n", status, hPllc);
        pllc_error_exit ();
        return;
    }

    /* Poll for divide-ratio change and clock alignment to complete */
    do {
        CSL_pllcGetHwStatus (hPllc, CSL_PLLC_QUERY_STATUS, &response);
    } while (response & CSL_PLLC_STATUS_GO);

    /* Close the module */
    status = CSL_pllcClose (hPllc);
    if (status != CSL_SOK) {
        printf ("PLLC: Close the instance ... Failed\n");
    }

    printf("PLLC example complete \n");

    return;
}

/*
 *  ============================================================================
 *  @func   pllc_error_exit
 *  ============================================================================
 */
void pllc_error_exit (
    void
)
{
    CSL_Status               status;

    /* Closes the module */
    status = CSL_pllcClose (hPllc);
    if (status != CSL_SOK) {
        printf ("PLLC: Close Pllc instance... Failed\n");
    }
}