8 Replies Latest reply on Mar 21, 2019 9:11 AM by jac_3880146

    Change PLL clock frequency with C

    jac_3880146

      I am trying to change the PLL clock using the cypress API functions, instead of the "Clocks" UI section. There is a "walkthrough" here: https://www.cypress.com/file/420571/download on page 132.

       

      My code looks something like this:

       

      int main(void)

      {

           uint32_t clkPath = 1;

          Cy_SysClk_ClkPathSetSource(clkPath, CY_SYSCLK_CLKPATH_IN_IMO);

       

          cy_stc_pll_manual_config_t* config;

          configNew->feedbackDiv = 25UL;

          configNew->referenceDiv = 1UL;

          configNew->outputDiv = 2UL;

          configNew->lfMode = true;

              Cy_SysClk_PllEnable(clkPathManual, 2); //  > 1us delay as suggested on step 3 of TRM   

           Cy_SysClk_PllManualConfigure(clkPath, config);

      ...

      }

       

      It seems that the PLL is already enabled when Cy_SysClk_PllManualConfigure() is called, and i get CY_SYSCLK_INVALID_STATE return code from the function. Any suggestions? Thanks in advance.