DSP快速复盘——时钟系统总结(基本知识+核心代码)基于TMS2802x处理器

本文详细介绍了DSP处理器的时钟系统结构,包括振荡器、锁相环和时钟机制等核心组件。通过分析关键寄存器配置及官方库文件初始化代码,帮助读者理解DSP时钟系统的运行原理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

写作背景:我最近在写一个DSP的项目,由于上一次接触DSP处理器写代码是在一两年之前,再加上之前主要是学习了STM32,关于DSP的一些知识已经忘记得差不多了。现在重新捡起DSP来,又要花费大量得时间来重新找资料,读文档。所以产生了写点东西得想法,主要的目的是把DSP的硬件知识(主要是寄存器相关)和软件初始化的核心代码记录下来,使自己未来再一次使用DSP时能够快速熟悉必要知识开始项目,最后把基本的代码打包,以达到快速复盘的目的。
注:虽然本文基于TMS2802x,是由于常用的几种DSP型号结构是差不多的,也可以用作其他型号芯片的入门资料。

参考文档标注在图片地下和文章结尾处。

1. 时钟系统的主要结构

DSP时钟系统被称为其“心脏”,的主要结构包括振荡器(SOC),锁相环(PLL)和时钟机制。此外还包括看门狗,低功耗模式等内容,另外DSP处理器还带有3个CPU计时器(CPU Timer0/1/2)。这篇主要介绍前三项内容,对于掌握DSP运行的时钟走向和后续其他模块设置十分重要。
OSC和PLL模块Page=58
上面的图片可以清晰看到时钟信号的流向,从振荡时钟OSCCLK,经过中间的PLL和时钟机制,在这个过程中PLL有可能不使用(一般是使用的)。最后图上的输出信号CLKIN,从英文名称上称为时钟输入信号,实际上它是CPU的输入信号,因此也就是最终的CPU频率。需要指出的是图中OSCCLK并不是指某一个具体的信号,这是因为在2802x中这个信号可以有多个来源,需要根据具体的寄存器设置才能决定,因此首先说一下OSCCLK信号。

1.1振荡时钟的输入源选择

时钟输入源选择Page=53
可以OSCCLK的来源主要有四个,两个内部振荡器,一个外部引脚输入和一个外部晶振。从上到下分别是internal OSC1,internal OSC2,XCLKIN以及外部晶振XTAL提供时基的(Crystal)OSC信号。需要注意的是XCLKIN和上一节提到的CLKIN的不同。四个信号经过层层“关卡”,最后只有某一个才能够成为OSCCLK,进而输入到PLL进行后面的“转换”。
常用的输入源是内部振荡OSC1和XTAL外部晶振信号。TI(德州仪器)官方给出的库文件初始化代码(后面会讲解),最终将输入源默认设置为10MHz,这已经完全够用。在平时项目中一般还会使用XTAL,也就是外部晶振作为时钟源。

1.2 锁相环PLL及时钟机制

这里再贴一次第一张图
时钟输入源选择Page=53
OSCCLK信号需要经过两层“关卡”才能到达CLKIN送入CPU。第一层是锁存器PLL,锁存器的作用是对OSCCLK信号进行n倍频,也就是把其信号频率提升n倍,同时也可以不使用PLL,直接把信号送到下一层“关卡”,通过PLLSTS[PLLOFF],即PLL状态寄存器的第二位可以控制是否使用PLL。DSP在复位时该位为0,默认打开PLL。使用PLL可以倍频提高CPU的运算速度。n的大小取决于PLLCR[DIV](PLL控制寄存器)的值进行设定。
PLL对OSCCLK进行倍频的同时,下一层“关卡”会对信号进行分频,因此CLKIN的频率最终由PLLCR[DIV]和PLLSTS[DIVSEL]这两个位决定,对频率进行先乘后除后送入CPU。

1.3 CPU时钟CLKIN与外设时钟的关系

在这里插入图片描述
C28x Core是CPU,CLKIN信号送入CPU后,经过CPU的分发,作为SYSCLKOUT信号送往各个外设,因此:SYSCLKOUT=CLKINSYSCLKOUT=CLKINSYSCLKOUT=CLKIN,但是部分低速外设还需要经过LOSPCP寄存器变成LSPCLK后提供给相关外设。进行ADC,SCI等相关外设的设置时需要知道这个具体的频率数值来进行计算。

2. 主要需要关注的寄存器和寄存器位。

PLL_Clocking_Watchdog_and_LowPower_Mode_Registers_page48
上图是DSP的系统控制寄存器(System Control Register File),包括了系统时钟相关的一系列寄存器,下面就重点提一下从时钟输入到CLKIN一路过来的主要寄存器和寄存器位。
主要是CLKCTL,这三个寄存器,复位后DSP内部的振荡器都处于开启状态,但是选择哪一个作为OSCCLK取决于CLKCTL的[OSCCLKSRCSEL]位,这一位复位默认为0,因此选择internal OSC1作为时钟源。之后便是PLLCR[DIV]和PLLSTS[DIVSEL]这两个寄存器共同决定CLKIN的频率。如下图所示:
PLL_Settings_page61
需要指出的是PLLCR[DIV]在上电时为0,处于被旁路状态(旁路但是PLL处于运行状态),OSCCLK被四分频(OSCCLK/4)送入后面的信号,这是为了防止DSP超频导致系统启动时出问题。在官方的库代码中,上电后会对这两个位进行设置,比如将PLLCR[DIV]设置为12,PLLSTS[DIVSEL]设置为2,因此最终CPU运行频率为:(OSCCLK=10MHz * 12) / 2 = 60MHz,这也是数据手册给出的最大运行频率。

3. 库文件的初始化代码

在官方给出的库文件DSP2802x_SysCtrl.c中,主函数main进入后的第一个函数InitSysCtrl()就是系统的初始话函数,包括的系统的时钟设置。

void InitSysCtrl(void)
{

   // Disable the watchdog
   DisableDog();

    // *IMPORTANT*
    // The Device_cal function, which copies the ADC & oscillator calibration values
    // from TI reserved OTP into the appropriate trim registers, occurs automatically
    // in the Boot ROM. If the boot ROM code is bypassed during the debug process, the
    // following function MUST be called for the ADC and oscillators to function according
    // to specification. The clocks to the ADC MUST be enabled before calling this
    // function.
    // See the device data manual and/or the ADC Reference
    // Manual for more information.

        EALLOW;
        SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1; // Enable ADC peripheral clock
        (*Device_cal)();
        SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 0; // Return ADC clock to original state
        EDIS;

   // Select Internal Oscillator 1 as Clock Source (default), and turn off all unused clocks to
   // conserve power.
   IntOsc1Sel();

   // Initialize the PLL control: PLLCR and DIVSEL
   // DSP28_PLLCR and DSP28_DIVSEL are defined in DSP2802x_Examples.h
   InitPll(DSP28_PLLCR,DSP28_DIVSEL);

   // Initialize the peripheral clocks
   InitPeripheralClocks();
}

首先的ADC的校准代码,这个放着先不管,之后是IntOscSel(),该函数选择内部振荡器OSC1作为时钟源,并关闭其他未使用的时钟来降低功耗。
然后是InitPLL(),用于设置PLLCR[DIV]和PLLSTS[DIVSEL]这两个位,具体实现方式不做描述。该函数具有两个参数,DSP28_PLLCRDSP28_DIVSEL,通过宏定义的方式来确定具体的数值。修改宏定义便能确定CLKIN的最终频率。
宏定义位于DSP2802x_Example.h中。

/*-----------------------------------------------------------------------------
      Specify the PLL control register (PLLCR) and divide select (DIVSEL) value.
-----------------------------------------------------------------------------*/

//#define DSP28_DIVSEL   0 // Enable /4 for SYSCLKOUT
//#define DSP28_DIVSEL   1 // Disable /4 for SYSCKOUT
#define DSP28_DIVSEL   2 // Enable /2 for SYSCLKOUT
//#define DSP28_DIVSEL   3 // Enable /1 for SYSCLKOUT


#define DSP28_PLLCR   12    // Uncomment for 60 MHz devices [60 MHz = (10MHz * 12)/2]
//#define DSP28_PLLCR   11
//#define DSP28_PLLCR   10      // Uncomment for 50 Mhz devices [50 Mhz = (10MHz * 10)/2]
//#define DSP28_PLLCR    9
//#define DSP28_PLLCR    8      // Uncomment for 40 MHz devices [40 MHz = (10MHz * 8)/2]
//#define DSP28_PLLCR    7
...
...

4.总结

总体来说,DSP的时钟系统虽然看起来比较复杂,但是对于初级的程序涉及到的寄存器和代码并不多,比较简单。
ps:还有一些图片和表述我觉得不够完善,后面再进行修改吧。

完整的 dsp2802芯片资料 包括 Contents 1 Architectural Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 Introduces the architecture and memory map of the T320C28x DSP CPU. 1.1 Introduction to the CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 1.1.1 Compatibility With Other TMS320 CPUs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 1.1.2 Switching to C28x Mode From Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 1.2 Components of the CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 1.2.1 Central Processing Unit (CPU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 1.2.2 Emulation Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5 1.2.3 Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6 1.3 Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 1.3.1 CPU Interrupt Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 1.4 Memory Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9 1.4.1 Address and Data Buses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9 1.4.2 Special Bus Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10 1.4.3 Alignment of 32-Bit Accesses to Even Addresses . . . . . . . . . . . . . . . . . . . . . . . 1-11 2 Central Processing Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 Describes the architecture, registers, and primary functions of the TMS320C28x CPU. 2.1 CPU Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 2.2 CPU Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4 2.2.1 Accumulator (ACC, AH, AL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 2.2.2 Multiplicand Register (XT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8 2.2.3 Product Register (P, PH, PL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 2.2.4 Data Page Pointer (DP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10 2.2.5 Stack Pointer (SP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11 2.2.6 Auxiliary Registers (XAR0−XAR7, AR0−AR7) . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12 2.2.7 Program Counter (PC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14 2.2.8 Return Program Counter (RPC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14 2.2.9 Status Registers (ST0, ST1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14 2.2.10 Interrupt-Control Registers (IFR, IER, DBGIER) . . . . . . . . . . . . . . . . . . . . . . . . 2-14 2.3 Status Register (ST0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16 2.4 Status Register ST1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34 2.5 Program Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39 2.5.1 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39 2.5.2 Branches, Calls, and Returns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39 Contents x 2.5.3 Repeating a Single Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39 2.5.4 Instruction Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-40 2.6 Multiply Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-41 2.6.1 16-bit X 16-bit Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-41 2.6.2 32-Bit X 32-Bit Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42 2.7 Shift Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-44 3 CPU Interrupts and Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1 Describes the TMS320C28x interrupts and how they are handled by the CPU. Also explains the effects of a hardware reset. 3.1 CPU Interrupts Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 3.2 CPU Interrupt Vectors and Priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 3.3 Maskable Interrupts: INT1−INT14, DLOGINT, and RTOSINT . . . . . . . . . . . . . . . . . . . . . 3-6 3.3.1 CPU Interrupt Flag Register (IFR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7 3.3.2 CPU Interrupt Enable Register (IER) and CPU Debug Interrupt Enable Register (DBGIER) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8 3.4 Standard Operation for Maskable Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11 3.5 Nonmaskable Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17 3.5.1 INTR Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17 3.5.2 TRAP Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18 3.5.3 Hardware Interrupt NMI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21 3.6 Illegal-Instruction Trap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22 3.7 Hardware Reset (RS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23 4 Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1 Describes the phases and operation of the instruction pipeline. 4.1 Pipelining of Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 4.1.1 Decoupled Pipeline Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4 4.1.2 Instruction-Fetch Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4 4.1.3 Address Counters FC, IC, and PC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5 4.2 Visualizing Pipeline Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7 4.3 Freezes in Pipeline Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10 4.3.1 Wait States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10 4.3.2 Instruction-Not-Available Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10 4.4 Pipeline Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12 4.4.1 Protection During Reads and Writes to the Same Data-Space Location . . . . 4-12 4.4.2 Protection Against Register Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13 4.5 Avoiding Unprotected Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16 4.5.1 Unprotected Program-Space Reads and Writes . . . . . . . . . . . . . . . . . . . . . . . . 4-16 4.5.2 An Access to One Location That Affects Another Location . . . . . . . . . . . . . . . 4-16 4.5.3 Write Followed By Read Protection Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17 Contents Contents xi 5 C28x Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1 Describes the addressing modes of the C28x. 5.1 Types of Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 5.2 Addressing Modes Select Bit (AMODE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 5.3 Assembler/Compiler Tracking of AMODE Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7 5.4 Direct Addressing Modes (DP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8 5.5 Stack Addressing Modes (SP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9 5.6 Indirect Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10 5.6.1 C28x Indirect Addressing Modes (XAR0 to XAR7) . . . . . . . . . . . . . . . . . . . . . . 5-10 5.6.2 C2xLP Indirect Addressing Modes (ARP, XAR0 to XAR7) . . . . . . . . . . . . . . . . 5-12 5.6.3 Circular Indirect Addressing Modes (XAR6, XAR1) . . . . . . . . . . . . . . . . . . . . . . 5-21 5.7 Register Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25 5.7.1 32-Bit Register Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25 5.7.2 16-Bit Register Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26 5.8 Data/Program/IO Space Immediate Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . 5-28 5.9 Program Space Indirect Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-30 5.10 Byte Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-31 5.11 Alignment of 32-Bit Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-33 6 C28x Assembly Language Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1 Presents summaries of the instruction set, defines special symbols and notations used, and describes each instruction in detail in alphabetical order. 6.1 Instruction Set Summary (Organized by Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2 6.2 Register Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 7 Emulation Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1 Explains features supported by the TC2800 CPU for testing and debugging programs. 7.1 Overview of Emulation Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2 7.2 Debug Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3 7.3 Debug Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6 7.4 Execution Control Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7 7.4.1 Stop Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7 7.4.2 Real-Time Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9 Caution about breakpoints within time-critical interrupt service routines . . . . 7-11 7.4.3 Summary of Stop Mode and Real-Time Mode . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11 7.5 Aborting Interrupts With the ABORTI Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-15 7.6 DT-DMA Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-16 7.7 Analysis Breakpoints, Watchpoints, and Counter(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19 7.7.1 Analysis Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19 7.7.2 Watchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19 7.7.3 Benchmark Counter/Event Counter(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20 7.7.4 Typical Analysis Unit Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-21 Contents xii 7.8 Data Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-23 7.8.1 Creating a Data Logging Transfer Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-23 7.8.2 Accessing the Emulation Registers Properly . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26 7.8.3 Data Log Interrupt (DLOGINT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-27 7.8.4 Examples of Data Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-28 7.9 Sharing Analysis Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-30 7.10 Diagnostics and Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-31 A Register Quick Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1 Is a concise, central resource for information about the status and control registers of the TMS320C28x CPU. A.1 Reset Values of and Instructions for Accessing the Registers . . . . . . . . . . . . . . . . . . . . . A-2 A.2 Register Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3 B C2xLP and C28x Architectural Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-1 Highlights some the architectural differences between C2xLP and C28x, with a focus on registers and memory maps. FB.1 Summary of Architecture Differences Between C2xLP and C28x . . . . . . . . . . . . . . . . . . B-2 B.1.1 Enhancements of the C28x over the C2xLP: . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-2 B.2 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-3 B.2.1 CPU Register Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-4 B.2.2 Data Page (DP) Pointer Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-5 B.2.3 Status Register Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-7 B.2.4 Register Reset Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-10 B.3 Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-12 C C2xLP Migration Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-1 Provides guidelines for C2xLP code migration to a C28x device. C.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-2 C.2 Recommended Migration Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-3 C.3 Mixing C2xLP and C28x Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-6 C.4 Code Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-7 C.4.1 Boot Code for C28x operating mode initalization . . . . . . . . . . . . . . . . . . . . . . . . . C-7 C.4.2 IER/IFR Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-7 C.4.3 Context Save/Restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-8 C.5 Reference Tables for C2xLP Code Migration Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-10 D C2xLP Instruction Set Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-1 Describes the instruction set compatibility between the C2xLP and the C28x. D.1 Condition Tests on Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-2 D.2 C2xLP vs. C28x Mnemonics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-3 D.3 Repeatable Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-9 Contents Contents xiii E Migration From C27x to C28x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-1 Highlights the architectural differences between C27x and C28x and describes how to migrate your code from C27x to C28x E.1 Architecture Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-2 E.1.1 Changes to Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-2 E.1.2 Full Context Save and Restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-5 E.1.3 B0/B1 Memory Map Consideration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-6 E.1.4 C27x Object Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-8 E.2 Moving to a C28x Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-9 E.2.1 Caution When Changing OJBMODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-9 E.3 Migrating to C28x Object Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-11 E.3.1 Instruction Syntax Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-11 E.3.2 Repeatable Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-13 E.3.3 Changes to the SUBCU Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-14 E.4 Compiling C28x Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-16 F Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-1 Figures xiv Figures 1−1 High-Level Conceptual Diagram of the CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 1−2 TMS320C28x High-Level Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8 2−1 Conceptual Block Diagram of the CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 2−2 C28x Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 2−3 Individually Accessible Portions of the Accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 2−4 Individually Accessible Halves of the XT Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 2−5 Individually Accessible Halves of the P Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 2−6 Pages of Data Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11 2−7 Address Reach of the Stack Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12 2−8 XAR0 − XAR7 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13 2−9 XAR0 − XAR7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13 2−10 Bit Fields of Status Register (ST0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16 2−11 Bit Fields of Status Register 1 (ST1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34 2−12 Conceptual Diagram of Components Involved in 16 X16-Bit Multiplication . . . . . . . . . . . 2-42 2−13 Conceptual Diagram of Components Involved in 32 X 32-Bit Multiplication . . . . . . . . . . . 2-43 3−1 Interrupt Flag Register (IFR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7 3−2 Interrupt Enable Register (IER) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9 3−3 Debug Interrupt Enable Register (DBGIER) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10 3−4 Standard Operation for CPU Maskable Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12 3−5 Functional Flow Chart for an Interrupt Initiated by the TRAP Instruction . . . . . . . . . . . . . 3-18 5−1 Circular Buffer with AMODE = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22 5−2 Circular Buffer with AMODE = 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24 7−1 JTAG Header to Interface a Target to the Scan Controller . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3 7−2 Stop Mode Execution States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8 7−3 Real-time Mode Execution States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10 7−4 Stop Mode Versus Real-Time Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12 7−5 Process for Handling a DT-DMA Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17 7−6 ADDRL (at Data-Space Address 00 083816) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-24 7−7 ADDRH (at Data-Space Address 00 083916) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-24 7−8 REFL (at Data-Space Address 00 084A16) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-24 7−9 REFH (at Data-Space Address 00 084B16) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-24 7−10 Valid Combinations of Analysis Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-30 A−1 Status register ST0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-4 A−2 Status register ST1, Bits15−8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-5 A−3 Status Register ST1, Bits 7−0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-6 A−4 Interrupt flag register (IFR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-7 Figures Contents xv A−5 Interrupt enable register (IER) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-8 A−6 Debug interrupt enable register (DBGIER) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-9 B−1 Register Changes From C2xLP to C28x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-3 B−2 Direct Addressing Mode Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-6 B−3 Status Register Comparison Between C2xLP and C28x . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-7 B−4 Memory Map Comparison (See Note A) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-13 C−1 Flow Chart of Recommended Migration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-4 E−1 C28x Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-2 E−2 Full Context Save/Restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-5 E−3 Code for a Full Context Save/Restore for C28x vs C27x . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-6 E−4 Mapping of Memory Blocks B0 and B1 on C27x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-7 E−5 C27x Compatible Mapping of Blocks M0 and M1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-7 E−6 Building a C27x Object File From C27x Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-8 E−7 Building a C28x Object File From Mixed C27x/C28x Source . . . . . . . . . . . . . . . . . . . . . . . . E-9 E−8 Compiling C28x Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值