TMS320F28027之創建工程

       參照TI的driver_example創建CCS5.2的工程,要求絕對的移植性,這個工程複製到任何一臺裝有CCS v5的電腦上都能編譯通過,不需要改動任何地方,包括路徑。

       首先,下載安裝TI的2802x C/C++ Header Files and PeripheralExamples,以2802x爲例,下載地址:http://www.ti.com/tool/sprc832

        建立一個文件夾,按照項目的意義命名,最好保存在全英文路徑目錄下。


        然後,把2802x C/C++ Header Files andPeripheral Examples安裝目錄下的DSP2802x_common文件夾和DSP2802x_headers文件夾複製到這個文件夾裏。


       然後在這個文件夾裏在新建一個文件夾,命名爲project。


       在2802x C/C++ Header Files andPeripheral Examples安裝目錄下找到需要用到的cmd文件和asm文件複製到這個文件夾下,如下圖:


       在此文件夾下新建一個文件夾,命名爲src:

 

      打開src文件夾,在2802x C/C++ Header Files andPeripheral Examples安裝目錄下找到這些文件複製到src中


      如果還需要其他的文件,比如要用到AD,就把DSP2802x_Adc.c文件也複製到此文件夾中,這個文件夾用來放c語言的源文件。

       然後,打開CCS v5。單擊Project,選擇New CCS Project。按下圖設置:


      

       然後看到ccs左側的資源管理視圖中已經出現了我們剛剛建立的test的工程。我們剛剛建立的test的工程。


      

     右擊test項目,單擊Properties



在General下可以設置芯片,仿真器,cmd文件等


Optimization頁面下可以設置優化等級。

Include Options頁面可以設置頭文件路徑。我們如下設置:


在Predefined Symbols頁面下可以定義一些宏,用於條件編譯等

在C2000 Linker下的File Search Path頁面可以設置庫文件的路徑。我們如下設置:



右擊src,新建一個文件,這裏命名爲main.c


在main.c中寫下測試程序,點擊編譯,如果有c2000 Launchpad,點擊Debug,把程序下到tms320f28027的ram裏調試,將會看到板子上的流水燈。以後創建工程就以此爲模板,複製修改即可。


測試代碼:

#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

void Gpio_select(void);

void main(void)
{

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2802x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initalize GPIO:
// This example function is found in the DSP2802x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();  // Skipped for this example

// For this example use the following configuration:
   Gpio_select();

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2802x_PieCtrl.c file.
   InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in DSP2802x_DefaultIsr.c.
// This function is found in DSP2802x_PieVect.c.
   InitPieVectTable();


// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2802x_InitPeripherals.c
// InitPeripherals(); // Not required for this example

// Step 5. User specific code:

   while(1)
   {
	   GpioDataRegs.GPADAT.all = 0x0000000e;
	   DELAY_US(1000000);
	   GpioDataRegs.GPADAT.all = 0x0000000d;
	   DELAY_US(1000000);
	   GpioDataRegs.GPADAT.all = 0x0000000b;
	   DELAY_US(1000000);
	   GpioDataRegs.GPADAT.all = 0x00000007;
	   DELAY_US(1000000);
   }
}

void Gpio_select(void)
{

    EALLOW;
	GpioCtrlRegs.GPAMUX1.all = 0x00000000;  // All GPIO
	GpioCtrlRegs.GPAMUX2.all = 0x00000000;  // All GPIO
	GpioCtrlRegs.GPBMUX1.all = 0x00000000;  // All GPIO
    GpioCtrlRegs.GPADIR.all = 0xFFFFFFFF;   // All outputs
    GpioCtrlRegs.GPBDIR.all = 0x0000000F;   // All outputs
    EDIS;

}
//=========================================================================
// No more.
//=========================================================================






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章