DSP

【创龙TMS320C6748开发板试用】+两张图,看清时钟

2019-07-13 12:10发布

一直在看例程 ,但现例程中没有时钟的配置程序,一开始也没有在意,现在把例程都试差不多了,反回来想想,有点费解。
由于没有看视频,今天发现视频里有一节是讲时钟的,就下载下来看成了一下。还是挻详细的。
原来时钟的配置在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

  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

  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

  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

  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

  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

  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

  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

  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文件了。