TMS320/Study2014. 8. 7. 04:01

공부하는 내용




Start!

◎코드에 반드시 집어넣는 헤더파일 DSP281x_Device.h의 이해는 반드시 필요할 것이다.

가장 큰 역할 : DSP의 MMR(Memory Mapped Register)이 선언된 헤더 파일 전체를 포함.

DSP의 MMR은 기능단위로 쪼개져 있어 여러 헤더파일에 걸쳐 선언되어 있다. 프로그래밍에서 이들을 일일이 include할 수도 없는 노릇이기에 이를 통합하는 것이 DSP281x_Device.h이다.

◎MMR은 Header_nonBios.cmd에 선언되어 있다.



코드 분석을 해보자

 

1.

 

#define   TARGET   1
//---------------------------------------------------------------------------
// User To Select Target Device:

#define   DSP28_F2812   TARGET
#define   DSP28_F2811   0
#define   DSP28_F2810   0

 

TARGET을 1이라는 값으로 명명하고 DSP28_F2812가 TARGET으로 명명되었다. 즉, DSSP28_F2812가 1이라고 명명된것.

 

2.

 

#define  EINT   asm(" clrc INTM")
#define  DINT   asm(" setc INTM")
#define  ERTM   asm(" clrc DBGM")
#define  DRTM   asm(" setc DBGM")
#define  EALLOW asm(" EALLOW")
#define  EDIS   asm(" EDIS")
#define  ESTOP0 asm(" ESTOP0")

 

EINT등이 인라인 어셈블리 함수로 명명되어 있다. 앞서 보았었던 EALLOW, EDIS가 어셈블리 함수와 연결되어 있음을 알 수 있다.

 

3.

 

#define M_INT1  0x0001
#define M_INT2  0x0002
#define M_INT3  0x0004
#define M_INT4  0x0008
#define M_INT5  0x0010
#define M_INT6  0x0020
#define M_INT7  0x0040
#define M_INT8  0x0080
#define M_INT9  0x0100
#define M_INT10 0x0200
#define M_INT11 0x0400
#define M_INT12 0x0800
#define M_INT13 0x1000
#define M_INT14 0x2000

#define M_DLOG  0x4000
#define M_RTOS  0x8000

 

인터럽트 설정을 위한 비트마스크이다. 사용할 인터럽트에 대해서 M_INT1 등으로 명명해놓은것.

 

4.

 

#define BIT0    0x0001
#define BIT1    0x0002
#define BIT2    0x0004
#define BIT3    0x0008
#define BIT4    0x0010
#define BIT5    0x0020
#define BIT6    0x0040
#define BIT7    0x0080
#define BIT8    0x0100
#define BIT9    0x0200
#define BIT10   0x0400
#define BIT11   0x0800
#define BIT12   0x1000
#define BIT13   0x2000
#define BIT14   0x4000
#define BIT15   0x8000

 

일반 레지스터 조작의 접근편이성을 위해서 BIT0,1 등으로 명명해 놓았다.

 

5.

 

#ifndef DSP28_DATA_TYPES
#define DSP28_DATA_TYPES
typedef int                 int16;
typedef long                int32;
typedef long long           int64;
typedef unsigned int        Uint16;
typedef unsigned long       Uint32;
typedef unsigned long long  Uint64;
typedef float               float32;
typedef long double         float64;
#endif

 

DSP28_DATA_TYPES 이 전처리기로 선언되어 있지 않으면/ 선언해주고 typedef로 int16등에 int등의 별칭을 붙여준다.

 

6.

 

#include "DSP281x_SysCtrl.h"            // System Control/Power Modes
#include "DSP281x_DevEmu.h"             // Device Emulation Registers
#include "DSP281x_Xintf.h"              // External Interface Registers
#include "DSP281x_CpuTimers.h"          // 32-bit CPU Timers
#include "DSP281x_PieCtrl.h"            // PIE Control Registers
#include "DSP281x_PieVect.h"            // PIE Vector Table
#include "DSP281x_Spi.h"                // SPI Registers
#include "DSP281x_Sci.h"                // SCI Registers
#include "DSP281x_Mcbsp.h"              // McBSP Registers
#include "DSP281x_ECan.h"               // Enhanced eCAN Registers
#include "DSP281x_Gpio.h"               // General Purpose I/O Registers
#include "DSP281x_Ev.h"                 // Event Manager Registers
#include "DSP281x_Adc.h"                // ADC Registers
#include "DSP281x_XIntrupt.h"           // External Interrupts

 

마지막으로 각종 헤더파일을 인클루드 하고 있다.

 

예를들어서 DSP281x_Adc.h는 ADC와 관련된 레지스터가 구조체 형식으로 정의되어 있고 .c파일에서 초기화 함수가 선언되어 있다.

'TMS320 > Study' 카테고리의 다른 글

cmd 파일  (0) 2014.08.07
DSP281x_GlobalVariableDefs.c  (0) 2014.08.07
DSP281x_SysCtrl.c <좀더 자세히>  (0) 2014.08.06
전처리기(Precompiler) pragma  (0) 2014.08.06
DSP281x_SysCtrl.c  (0) 2014.08.06
Posted by 십자성군