【創龍TMS320C6748開發板試用】+兩張圖,看清時鐘

南方的小清湖發表於2017-01-22
一直在看例程 ,但現例程中沒有時鐘的配置程式,一開始也沒有在意,現在把例程都試差不多了,反回來想想,有點費解。
由於沒有看視訊,今天發現視訊裡有一節是講時鐘的,就下載下來看成了一下。還是挻詳細的。
原來時鐘的配置在gel檔案中。
根據視訊的講解,做了下面兩張圖,算是把時鐘部分的要點總結一下,再深入就是研究DSP的了,而我們這些只是會用就行了。
以下是兩個時鐘PLL0與PLL1的產生。
 

下面是兩個時鐘的一些引數。
 

之於時鐘的配置可以在gel檔案中的device_PLL0與device_PLL1兩個函式中。
  1. device_PLL0(unsigned int CLKMODE, unsigned int PLLM, unsigned int POSTDIV,unsigned int PLLDIV1, unsigned int PLLDIV2, unsigned int PLLDIV3, unsigned int PLLDIV7 ) {

  2.     unsigned int i=0;

  3.     /* Clear PLL lock bit */
  4.     CFGCHIP0 &= ~(0x00000010);

  5.     /* Set PLLENSRC '0',bit 5, PLL Enable(PLLEN) selection is controlled through MMR */
  6.     PLL0_PLLCTL &= ~(0x00000020);

  7.     /* PLLCTL.EXTCLKSRC bit 9 should be left at 0 for Freon */
  8.     PLL0_PLLCTL &= ~(0x00000200);

  9.     /* Set PLLEN=0 to put in bypass mode*/
  10.     PLL0_PLLCTL &= ~(0x00000001);

  11.     /*wait for 4 cycles to allow PLLEN mux switches properly to bypass clock*/
  12.     for(i=0; i<PLLEN_MUX_SWITCH; i++) {;}

  13.     /* Select the Clock Mode bit 8 as External Clock or On Chip Oscilator*/
  14.     PLL0_PLLCTL &= 0xFFFFFEFF;
  15.     PLL0_PLLCTL |= (CLKMODE << 8);

  16.     /*Clear PLLRST bit to reset the PLL */
  17.     PLL0_PLLCTL &= ~(0x00000008);

  18.     /* Disable the PLL output*/
  19.     PLL0_PLLCTL |= (0x00000010);

  20.     /* PLL initialization sequence
  21.     Power up the PLL by setting PWRDN bit set to 0 */
  22.     PLL0_PLLCTL &= ~(0x00000002);

  23.     /* Enable the PLL output*/
  24.     PLL0_PLLCTL &= ~(0x00000010);

  25.     /*PLL stabilisation time- take out this step , not required here when PLL in bypassmode*/
  26.     for(i=0; i<PLL_STABILIZATION_TIME; i++) {;}

  27.     /*Program the required multiplier value in PLLM*/
  28.     PLL0_PLLM    = PLLM;

  29.     /*If desired to scale all the SYSCLK frequencies of a given PLLC, program the POSTDIV ratio*/
  30.     PLL0_POSTDIV = 0x8000 | POSTDIV;

  31.     /*Check for the GOSTAT bit in PLLSTAT to clear to 0 to indicate that no GO operation is currently in progress*/
  32.     while(PLL0_PLLSTAT & 0x1==1){}

  33.     /*Program the RATIO field in PLLDIVx with the desired divide factors. In addition, make sure in this step you leave the PLLDIVx.DxEN bits set so clocks are still enabled (default).*/
  34.     PLL0_PLLDIV1 = 0x8000 | PLLDIV1;             // Fixed Ratio /1
  35.     PLL0_PLLDIV2 = 0x8000 | PLLDIV2;             // Fixed Ratio /2
  36.     PLL0_PLLDIV4 = 0x8000 | (((PLLDIV1+1)*4)-1); // Fixed Ratio /4
  37.     PLL0_PLLDIV6 = 0x8000 | PLLDIV1;             // Fixed Ratio /1
  38.     PLL0_PLLDIV3 = 0x8000 | PLLDIV3;             // Variable Ratio (EMIF)
  39.     PLL0_PLLDIV7 = 0x8000 | PLLDIV7;             // Variable Ratio (RMII)


  40.     /*Set the GOSET bit in PLLCMD to 1 to initiate a new divider transition.*/
  41.     PLL0_PLLCMD |= 0x1;

  42.     /*Wait for the GOSTAT bit in PLLSTAT to clear to 0 (completion of phase alignment).*/
  43.     while(PLL0_PLLSTAT & 0x1==1) { }

  44.     /*Wait for PLL to reset properly.*/
  45.     for(i=0; i<PLL_RESET_TIME_CNT; i++) {;}

  46.     /*Set the PLLRST bit in PLLCTL to 1 to bring the PLL out of reset*/
  47.     PLL0_PLLCTL |= 0x8;

  48.     /*Wait for PLL to lock.*/
  49.     for(i=0; i<PLL_LOCK_TIME_CNT; i++) {;}

  50.     /*Set the PLLEN bit in PLLCTL to 1 to remove the PLL from bypass mode*/
  51.     PLL0_PLLCTL |=  0x1;
  52. }

  53. /**********************************************************************************
  54. DDR PLL1 init:

  55. ***********************************************************************************/
  56. device_PLL1(unsigned int PLLM,unsigned int POSTDIV,unsigned int PLLDIV1, unsigned int PLLDIV2, unsigned int PLLDIV3 ) {

  57.     unsigned int i=0;

  58.     /* Clear PLL lock bit */
  59.     CFGCHIP3 &= ~(0x00000020);

  60.     /* Set PLLENSRC '0',bit 5, PLL Enable(PLLEN) selection is controlled through MMR */
  61.     PLL1_PLLCTL &= ~(0x00000020);

  62.     /* PLLCTL.EXTCLKSRC bit 9 should be left at 0 for Freon */
  63.     PLL1_PLLCTL &= ~(0x00000200);

  64.     /* Set PLLEN=0 to put in bypass mode*/
  65.     PLL1_PLLCTL &= ~(0x00000001);

  66.     /*wait for 4 cycles to allow PLLEN mux switches properly to bypass clock*/
  67.     for(i=0; i<PLLEN_MUX_SWITCH; i++) {;}

  68.     /*Clear PLLRST bit to reset the PLL */
  69.     PLL1_PLLCTL &= ~(0x00000008);

  70.     /* Disable the PLL output*/
  71.     PLL1_PLLCTL |= (0x00000010);

  72.     /* PLL initialization sequence
  73.     Power up the PLL by setting PWRDN bit set to 0 */
  74.     PLL1_PLLCTL &= ~(0x00000002);

  75.     /* Enable the PLL output*/
  76.     PLL1_PLLCTL &= ~(0x00000010);

  77.     /*PLL stabilisation time- take out this step , not required here when PLL in bypassmode*/
  78.     for(i=0; i<PLL_STABILIZATION_TIME; i++) {;}

  79.     /*Program the required multiplier value in PLLM*/
  80.     PLL1_PLLM    = PLLM;

  81.     /*If desired to scale all the SYSCLK frequencies of a given PLLC, program the POSTDIV ratio*/
  82.     PLL1_POSTDIV = 0x8000 | POSTDIV;

  83.     /*Check for the GOSTAT bit in PLLSTAT to clear to 0 to indicate that no GO operation is currently in progress*/
  84.     while(PLL1_PLLSTAT & 0x1==1){}

  85.     /*Program the RATIO field in PLLDIVx with the desired divide factors. In addition, make sure in this step you leave the PLLDIVx.DxEN bits set so clocks are still enabled (default).*/
  86.     PLL1_PLLDIV1 = 0x8000 | PLLDIV1;   // DDR frequency (aka 2X_CLK)
  87.     PLL1_PLLDIV2 = 0x8000 | PLLDIV2;   // Optional CFGCHIP3[ASYNC3_CLKSRC] clock source
  88.     PLL1_PLLDIV3 = 0x8000 | PLLDIV3;   // Optional PLL0 clock source

  89.     /*Set the GOSET bit in PLLCMD to 1 to initiate a new divider transition.*/
  90.     PLL1_PLLCMD |= 0x1;

  91.     /*Wait for the GOSTAT bit in PLLSTAT to clear to 0 (completion of phase alignment).*/
  92.     while(PLL1_PLLSTAT & 0x1==1) { }

  93.     /*Wait for PLL to reset properly */
  94.     for(i=0; i<PLL_RESET_TIME_CNT; i++) {;}

  95.     /*Set the PLLRST bit in PLLCTL to 1 to bring the PLL out of reset*/
  96.     PLL1_PLLCTL |= 0x8;

  97.     /*Wait for PLL to lock. See PLL spec for PLL lock time*/
  98.     for(i=0; i<PLL_LOCK_TIME_CNT; i++) {;}

  99.     /*Set the PLLEN bit in PLLCTL to 1 to remove the PLL from bypass mode*/
  100.     PLL1_PLLCTL |=  0x1;
  101. }
複製程式碼


其實gel檔案中所做的工作還是很多的。之前用28335的時候沒怎麼在意gel檔案,所有的配置都是在C程式中的,看來有必要學習一下gel檔案了。

相關文章