您的位置 首页 知识

LM3S9B96 读写寄存器的两种方法

可以通过两种方式读写寄存器1.在hw_types.h文件中//*********************************************************************

能够经过两种方法读写寄存器

1. 在hw_types.h文件中


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

运用方法:在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; // 拜访方法是:直接写寄存器的物理地址

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/zhishi/275160.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部