新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > LM3S9B96 讀寫寄存器的兩種方式

        LM3S9B96 讀寫寄存器的兩種方式

        作者: 時間:2016-11-11 來源:網(wǎng)絡(luò) 收藏
        可以通過兩種方式讀寫寄存器
        1. 在hw_types.h文件中

        //*****************************************************************************
        //
        // Macros for hardware access, both direct and via the bit-band region.
        //
        //*****************************************************************************
        #define HWREG(x) (*((volatile unsigned long *)(x))) // 使用位段方式訪問寄存器

        本文引用地址:http://www.104case.com/article/201611/317013.htm

        使用方法:在main.c中包含hw_types.h文件

        HWREG(ETH_BASE + MAC_O_TR) = 0; // 訪問方式是:寄存器的基址+偏移地址


        2. 在lm3s9b96.h文件中定義所有寄存器的物理地址:基址+偏移地址

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

        //
        // GPIO registers (PORTA)
        //
        //*****************************************************************************
        #define GPIO_PORTA_DATA_BITS_R ((volatile unsigned long *)0x40004000)
        #define GPIO_PORTA_DATA_R (*((volatile unsigned long *)0x400043FC))
        #define GPIO_PORTA_DIR_R (*((volatile unsigned long *)0x40004400))
        #define GPIO_PORTA_IS_R (*((volatile unsigned long *)0x40004404))
        #define GPIO_PORTA_IBE_R (*((volatile unsigned long *)0x40004408))
        #define GPIO_PORTA_IEV_R (*((volatile unsigned long *)0x4000440C))
        #define GPIO_PORTA_IM_R (*((volatile unsigned long *)0x40004410))
        #define GPIO_PORTA_RIS_R (*((volatile unsigned long *)0x40004414))
        #define GPIO_PORTA_MIS_R (*((volatile unsigned long *)0x40004418))
        #define GPIO_PORTA_ICR_R (*((volatile unsigned long *)0x4000441C))
        #define GPIO_PORTA_AFSEL_R (*((volatile unsigned long *)0x40004420))
        #define GPIO_PORTA_DR2R_R (*((volatile unsigned long *)0x40004500))
        #define GPIO_PORTA_DR4R_R (*((volatile unsigned long *)0x40004504))
        #define GPIO_PORTA_DR8R_R (*((volatile unsigned long *)0x40004508))
        #define GPIO_PORTA_ODR_R (*((volatile unsigned long *)0x4000450C))
        #define GPIO_PORTA_PUR_R (*((volatile unsigned long *)0x40004510))
        #define GPIO_PORTA_PDR_R (*((volatile unsigned long *)0x40004514))
        #define GPIO_PORTA_SLR_R (*((volatile unsigned long *)0x40004518))
        #define GPIO_PORTA_DEN_R (*((volatile unsigned long *)0x4000451C))
        #define GPIO_PORTA_LOCK_R (*((volatile unsigned long *)0x40004520))
        #define GPIO_PORTA_CR_R (*((volatile unsigned long *)0x40004524))
        #define GPIO_PORTA_AMSEL_R (*((volatile unsigned long *)0x40004528))
        #define GPIO_PORTA_PCTL_R (*((volatile unsigned long *)0x4000452C))

        使用方法:在main.c中包含lm3s9b96.h文件

        HWREG(GPIO_PORTA_DATA_R) = 0; // 訪問方式是:直接寫寄存器的物理地址




        關(guān)鍵詞: LM3S9B96讀寫寄存

        評論


        技術(shù)專區(qū)

        關(guān)閉
        主站蜘蛛池模板: 平舆县| 嘉定区| 明溪县| 镇宁| 西充县| 贵定县| 朝阳县| 平山县| 禹州市| 博湖县| 辽源市| 龙口市| 崇州市| 远安县| 平南县| 清新县| 施甸县| 德阳市| 湖北省| 陵川县| 永昌县| 乌兰县| 宜昌市| 卓资县| 博乐市| 沙洋县| 高雄县| 吉首市| 城步| 安丘市| 库尔勒市| 随州市| 曲麻莱县| 杨浦区| 富民县| 周至县| 棋牌| 苏州市| 闽清县| 宿迁市| 正阳县|