1. 程式人生 > >1、DSP28335 硬體概述與暫存器描述

1、DSP28335 硬體概述與暫存器描述

1、DSP28335晶片是TI公司,偏向於控制方向、浮點型處理器,通過了解可以看出該晶片具有眾多的外設,這這裡只是將它看成一個超級微控制器。其中這些外設的功能也很強大(複雜),所以在這裡並不去深究他們的功能,而是隻看他們的暫存器。

思路:

DSP資料手冊-》外設功能---》暫存器名稱+地址+時序圖。

多功能的管腳通過暫存器去配置。

在這裡不對DSP的具體外設列表與功能展開,有興趣的可以去查閱晶片手冊。


2、外設暫存器在標頭檔案定義

外設暫存器名字+地址+功能描述


使用#define 將暫存器名稱與地址聯絡起來


有了以上的聯絡,在程式中可以使用指標(暫存器名字)給暫存器賦值。


在暫存器中有很多單獨定義的位域暫存器,對位單獨定義可以在程式中使用更加靈活。

/********************************************************************

* SCI header file

********************************************************************/

//----------------------------------------------------------

// SCICCR communication control register bit definitions:

//

struct      SCICCR_BITS {                 // bit deion

Uint16    SCICHAR:3;                       // 2:0 Character length control

Uint16    ADDRIDLE_MODE:1;        // 3 ADDR/IDLE Mode control

Uint16    LOOPBKENA:1;                 // 4 Loop Back enable

Uint16    PARITYENA:1;                  // 5 Parity enable

Uint16    PARITY:1;                         // 6 Even or Odd Parity

Uint16    STOPBITS:1;                      // 7 Number of Stop Bits

Uint16    rsvd1:8;                              // 15:8 reserved

};

//-------------------------------------------

// SCICTL1 control register 1 bit definitions:

//

struct SCICTL1_BITS {                            // bit deion

Uint16    RXENA:1;                          // 0 SCI receiver enable

Uint16    TXENA:1;                          // 1 SCI transmitter enable

Uint16    SLEEP:1;                           // 2 SCI sleep

Uint16    TXWAKE:1;                       // 3 Transmitter wakeup method

Uint16    rsvd:1;                                // 4 reserved

Uint16    SWRESET:1;                      // 5 Software reset

Uint16    RXERRINTENA:1;             // 6 Receive interrupt enable

Uint16    rsvd1:9;                              // 15:7 reserved

};

在上面的定義中,使用了操作符“:”,用來說明位域的長度,即當前位域佔幾位。

使用聯合體。除了能夠方便的訪問位域外,有時候也希望能夠對暫存器整體訪問,使用聯合體能夠實現這種操作。

/********************************************************************

* SCI header file

********************************************************************/

union SCICCR_REG {

Uint16                                all;

struct      SCICCR_BITS      bit;

};

union SCICTL1_REG {

Uint16                                all;

struct      SCICTL1_BITS     bit;

};

7)、將新增位域後的暫存器結構體重新實現。

/********************************************************************

* SCI header file

* Defines a register file structure for the SCI peripheral

********************************************************************/

#define    Uint16    unsigned int

#define    Uint32    unsigned long

struct SCI_REGS {

Uint16    SCICCR_REG      SCICCR;             // Communications control register

Uint16    SCICTL1_REG     SCICTL1;             // Control register 1

Uint16                                SCIHBAUD;         // Baud rate (high) register

Uint16                                SCILBAUD;         // Baud rate (low) register

Uint16    SCICTL2_REG     SCICTL2;             // Control register 2

Uint16  SCIRXST_REG    SCIRXST;            // Receive status register

Uint16                               SCIRXEMU;               // Receive emulation buffer register

Uint16  SCIRXBUF_REG SCIRXBUF;         // Receive data buffer

Uint16                               rsvd1;                   // reserved

Uint16                               SCITXBUF;          // Transmit data buffer

Uint16  SCIFFTX_REG     SCIFFTX;            // FIFO transmit register

Uint16  SCIFFRX_REG    SCIFFRX;            // FIFO receive register

Uint16  SCIFFCT_REG     SCIFFCT;             // FIFO control register

Uint16                               rsvd2;                   // reserved

Uint16                               rsvd3;                   // reserved

Uint16  SCIPRI_REG        SCIPRI;                      // FIFO Priority control

};

通過以上學習,可以對晶片有一個大致的瞭解,對28335的工程標頭檔案中暫存器的定義有一個初步的瞭解,在以後的使用中,即可直接呼叫暫存器名字對其進行操作,這就將資料手冊與標頭檔案相對應了。