微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > TI DSP入门芯片TMS320F28335

TI DSP入门芯片TMS320F28335

时间:07-22 来源:3721RD 点击:

的低四位和PLLSTS的第7、8位来决定。其详细的倍频值可以参照TMS320F28335的Datasheet。下面是F28335的时钟设置:

  void InitPll(Uint16 val, Uint16 divsel)

  {

  // Make sure the PLL is not running in limp mode

  if (SysCtrlRegs.PLLSTS.bit.MCLKSTS != 0)

  {

  // Missing external clock has been detected

  // Replace this line with a call to an appropriate

  // SystemShutdown(); function.

  asm(" ESTOP0");

  }

  // divSEL MUST be 0 before PLLCR can be changed from

  // 0x0000. It is set to 0 by an external reset XRSn

  // This puts us in 1/4

  if (SysCtrlRegs.PLLSTS.bit.divSEL != 0)

  {

  EALLOW;

  SysCtrlRegs.PLLSTS.bit.divSEL = 0;

  EDIS;

  }

  // Change the PLLCR

  if (SysCtrlRegs.PLLCR.bit.div != val)

  {

  EALLOW;

  // Before setting PLLCR turn off missing clock detect logic

  SysCtrlRegs.PLLSTS.bit.MCLKOFF = 1;

  SysCtrlRegs.PLLCR.bit.div = val;

  EDIS;

  // Optional: Wait for PLL to lock.

  // During this time the CPU will switch to OSCCLK/2 until

  // the PLL is stable. Once the PLL is stable the CPU will

  // switch to the new PLL value.

  //

  // This time-to-lock is monitored by a PLL lock counter.

  //

  // Code is not required to sit and wait for the PLL to lock.

  // However, if the code does anything that is timing critical,

  // and requires the correct clock be locked, then it is best to

  // wait until this switching has completed.

  // Wait for the PLL lock bit to be set.

  // The watchdog should be disabled before this loop, or fed within

  // the loop via ServiceDog()。

  // Uncomment to disable the watchdog

  DisableDog();

  while(SysCtrlRegs.PLLSTS.bit.PLLLOCKS != 1)

  {

  // Uncomment to service the watchdog

  // ServiceDog();

  }

  EALLOW;

  SysCtrlRegs.PLLSTS.bit.MCLKOFF = 0;

  EDIS;

  }

  // If switching to 1/2

 if((divsel == 1)||(divsel == 2))

  {

  EALLOW;

  SysCtrlRegs.PLLSTS.bit.divSEL = divsel;

  EDIS;

  }

  // If switching to 1/1

  // * First go to 1/2 and let the power settle

  // The time required will depend on the system, this is only an example

  // * Then switch to 1/1

  if(divsel == 3)

  {

  EALLOW;

  SysCtrlRegs.PLLSTS.bit.divSEL = 2;

  DELAY_US(50L);

  SysCtrlRegs.PLLSTS.bit.divSEL = 3;

  EDIS;

  }

  }

TMS320F28335 的外部中断总结:

  在这里我们要十分清楚DSP的中断系统。C28XX一共有16个中断源,其中有2个不可屏蔽的中断RESET和NMI、定时器1和定时器2分别使用中断13和14。这样还有12个中断都直接连接到外设中断扩展模块PIE上。说的简单一点就是PIE通过12根线与28335核的12个中断线相连。而PIE的另外一侧有12*8根线分别连接到外设,如AD、SPI、EXINT等等。这样PIE共管理12*8=96个外部中断。这12组大中断由28335核的中断寄存器IER来控制,即IER确定每个中断到底属于哪一组大中断(如IER |= M_INT12;说明我们要用第12组的中断,但是第12组里面的什么中断CPU并不知道需要再由PIEIER确定 )。接下来再由PIE模块中的寄存器PIEIER中的低8确定该中断是这一组的第几个中断,这些配置都要告诉CPU(我们不难想象到PIEIER共有12总即从PIEIER1-PIEIER12)。另外,PIE模块还有中断标志寄存器PIEIFR,同样它的低8位是来自外部中断的8个标志位,同样CPU的IFR寄存器是中断组的标志寄存器。由此看来,CPU的所有中断寄存器控制12组的中断,PIE的所有中断寄存器控制每组内8个的中断。除此之外,我们用到哪一个外部中断,相应的还有外部中断的寄存器,需要注意的就是外部中断的标志要自己通过软件来清零。而PIE和CPU的中断标志寄存器由硬件来清零。

  EALLOW; // This is needed to write to EALLOW protected registers

  PieVectTable.XINT2 = &ISRExint; //告诉中断入口地址

  EDIS; // This is needed to disable write to EALLOW protected registers

  PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block使能PIE

  PieCtrlRegs.PIEIER1.bit.INTx5= 1; //使能第一组中的中断5

  IER |= M_INT1; // Enable CPU 第一组中断

  EINT; // Enable Global interrupt INTM

  ERTM; // Enable Global realtime interrupt DBGM

也就是说,12组中的每个中断都要完成上面的相同配置,剩下的才是去配置自己的中断。如我们提到的EXINT,即外面来个低电平

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top