2回答

0收藏

定义F28027内部寄存器及寄存器地址分配

FPGA/DSP FPGA/DSP 5473 人阅读 | 2 人回复 | 2012-12-30

// TI File $Revision: /main/4 $
// Checkin $Date: October 16, 2009   15:43:43 $
//###########################################################################
//
// FILE:    DSP2802x_GlobalVariableDefs.c
//
// TITLE:   DSP2802x Global Variables and Data Section Pragmas.
//
//###########################################################################
// $TI Release: f2802x Support Library v210 $
// $Release Date: Mon Sep 17 09:13:31 CDT 2012 $
//###########################################################################

#include "F2802x_Device.h"     // DSP2802x Headerfile Include File

//---------------------------------------------------------------------------
// Define Global Peripheral Variables:
//
//----------------------------------------
#ifdef __cplusplus            //用于 C++代码
#pragma DATA_SECTION("AdcRegsFile")
#else                               //用于C 代码
#pragma DATA_SECTION(AdcRegs,"AdcRegsFile");
#endif
volatile struct ADC_REGS AdcRegs;//定义AdcRegs 是一个具有ADC_REGS 类型的变量

//采用#pragma 编译器声明,将
AdcRegs 变量分配到AdcRegsFile 数据区。C 或C++采用不同的#pragma 声明方式。当对一个C++程序进行编译时,编译器自动定义__cplusplus。

#ifdef、#else 及#endif 为预处理器条件编译指令。其中#ifdef 和#else 格式类似 C 中的if 和else。主要差异为预处理器不能识别标记代码块的大括号"{}",因此使用#else和#end if来标记指令块。上面指令的含义为:如果采用的是C++,则执行语#pragma DATA_SECTION("AdcRegsFile  ");倘若采用的是C,则执行语句#pragma DATA_SECTION(AdcRegs  ,"AdcRegsFile  ");

映射到外设寄存器
当每个结构体都分配到自身的数据区之后,通过使用链接命令文件DSP281x_Headers_nonBIOS.cmd,每个数据区都将被直接映射到外设内存映射寄存器上,如以下代码所示:
/*
// TI File $Revision: /main/6 $
// Checkin $Date: October 16, 2009   15:43:38 $
//###########################################################################
//
// FILE:    DSP2802x_Headers_nonBIOS.cmd
//
// TITLE:   DSP2802x Peripheral registers linker command file
//
// DESCRIPTION:
//
//          This file is for use in Non-BIOS applications.
//
//          Linker command file to place the peripheral structures
//          used within the DSP2802x headerfiles into the correct memory
//          mapped locations.
//
//          This version of the file includes the PieVectorTable structure.
//          For BIOS applications, please use the DSP2802x_Headers_BIOS.cmd file
//          which does not include the PieVectorTable structure.
//
//###########################################################################
// $TI Release: f2802x Support Library v210 $
// $Release Date: Mon Sep 17 09:13:31 CDT 2012 $
//###########################################################################
*/
MEMORY
{
PAGE 0:    /* Program Memory */
PAGE 1:    /* Data Memory */
ADC_RESULT  : origin = 0x000B00, length = 0x000020     /* ADC Results register */
ADC         : origin = 0x007100, length = 0x000080     /* ADC registers */
}

SECTIONS
{
/*** Peripheral Frame 0 Register Structures ***/

   AdcResultFile     : > ADC_RESULT,  PAGE = 1   

/*** Peripheral Frame 1 Register Structures ***/      

   AdcRegsFile       : > ADC,         PAGE = 1

了解连接命令文件(CMD文件)Piccolo-- F28027.cmd到
https://www.cirmall.com/bbs/foru ... 460&fromuid=753

}

/*
//===========================================================================
// End of file.
//===========================================================================
*/



通过把变量直接映射到外设寄存器的同一内存地址,用户采用C 代码对寄存器进行访问,只需要通过访问变量中所需的成员即可进行。例如:
    AdcRegs.ADCCTL1.bit.ADCBGPWD  = 1;      // Power ADC BG
    AdcRegs.ADCCTL1.bit.ADCREFPWD = 1;      // Power reference
    AdcRegs.ADCCTL1.bit.ADCPWDN   = 1;      // Power ADC
    AdcRegs.ADCCTL1.bit.ADCENABLE = 1;      // Enable ADC
    AdcRegs.ADCCTL1.bit.ADCREFSEL = 0;      // Select interal BG

这个世界成功人的总是少数,我们都只是平凡的人,我们需要有一种平凡且进取的心态去生活,不要期望有多少付出就一定有多少回报,相信没有付出就没有回报就可以了。
分享到:
回复

使用道具 举报

回答|共 2 个

倒序浏览

沙发

徐园平

发表于 2012-12-30 11:19:17 | 只看该作者

顶顶更健康啊
http://weibo.com/yyppxu
板凳

nuc尧

发表于 2012-12-30 14:11:29 | 只看该作者

不错,谢谢分享
您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条