关于cortex-M3/M4中Bit-banding的笔记

关于cortex-M3/M4中Bit-banding的笔记Bit-bandingBit-bandingmapsacompletewordofmemoryontoasinglebitinthebit-bandregion.Forexample,writingtooneofthealiaswordswillsetorclearthecorrespondingbitinthebitbandre


Jetbrains全系列IDE稳定放心使用

Bit-banding

Bit-banding maps a complete word of memoryonto a single bit in the bit-band region. For example, writing to one of thealias words will set or clear the corresponding bit in the bitband region.

This allows every individual bit in thebit-banding region to be directly accessible from a word-aligned address usinga single LDR instruction. It also allows individual bits to be toggled from Cwithout performing a read-modify-write sequence of instructions.

Address translation

The Cortex-M3 has two 32MB regions that maponto the two 1MB bit-band regions. The two regions are separate, one in theSRAM region and one in the peripheral region.

Each bit in the bit-band region is addressedsequentially in the 32MB alias region. For example, the eighth bit in thebit-band region can be accessed using the eighth word in the 32MB alias region.

Reading and writing to the bit-bandingregion

When writing to the alias regions bit 0 ofthe 32 bit word is used to set the value at the bit-banding region. Readingfrom the alias address will return the value from the bit-band region in bit 0and the other bits will be cleared.

You can also access the base bit-bandregion itself in the same way as normal memory, using word, half word, and byteaccesses.

 关于cortex-M3/M4中Bit-banding的笔记

The internal SRAM of the Stellaris® devicesis located at address 0x2000.0000 of the device memory
map. To reduce the number of time consuming read-modify-write (RMW) operations,ARM has
introduced bit-banding technology in the Cortex-M3 processor. With abit-band-enabled processor,
certain regions in the memory map (SRAM and peripheral space) can use addressaliases to access
individual bits in a single, atomic operation. The bit-band base is located ataddress 0x2200.0000.

 

The bit-band alias is calculated by usingthe formula:
bit-band alias = bit-band base + (byte offset * 32) + (bit number * 4)
For example, if bit 3 at address 0x2000.1000 is to be modified, the bit-bandalias is calculated as:
0x2200.0000 + (0x1000 * 32) + (3 * 4) = 0x2202.000C
With the alias address calculated, an instruction performing a read/write toaddress 0x2202.000C
allows direct access to only bit 3 of the byte at address 0x2000.1000.

 

//Hw_types.h   以Bit-banding方式访问双字寄存器x中的第b位

#define HWREGBITW(x, b)         \

       HWREG(((unsigned long)(x) & 0xF0000000) | 0x02000000 | \

              (((unsigned long)(x) &0x000FFFFF) << 5) | ((b) << 2))

 

#define HWREG(x)                                          \

       (*((volatile unsigned long *)(x)))

 

Example:

 

ulValue = 1234;

for(ulIdx = 0; ulIdx < 32; ulIdx++)

{

//set every bitof ulValue(word) to 1

         HWREGBITW(&ulValue,31 – ulIdx) = (0xFFFFFFFF >> (31-ulIdx)) & 1;

         UARTprintf(“\r%08x”,ulValue);

         Delay(1);

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/182482.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 【spring】注解方式的bean管理

    【spring】注解方式的bean管理【spring】注解方式的bean管理

    2022年4月25日
  • PyTorch安装最全流程

    PyTorch安装最全流程本文介绍基于Anaconda环境以及PyCharm软件结合,安装PyTorch深度学习框架。1.Anaconda安装下载链接:https://www.anaconda.com/1.1点击Next1.2点击同意1.3点击Next1.4选择目标文件夹,点击下一步1.5将Anaconda加入到系统变量安装成功后,在CMD中检查Anaconda时候加入到环境变量中。1.6单击启动AnacondaPrompt创建虚拟“房间”通过conda创建一个名为:pytorch.

    2022年6月24日
  • Linux下oracle创建表空间及用户「建议收藏」

    Linux下oracle创建表空间及用户「建议收藏」最近在测试flink的oracle-cdc,公司领导在没用的测试环境搭了一个oracle供我测试,一开始我是拒绝的,毕竟oracle除了crud,也不会别的,奈何拒绝不了,只能边学变做。1,登录sys用户sqlplus/assysdba2,查询用户表空间文件的路径,然后在此目录下创建新的表空间selectnamefromv$datafile;3,创建表空间,永久性表空间:一般保存表、视图、过程和索引等的数据CREATETABLESPACExxxxLOGGINGDATAFI

    2022年7月11日
  • sqlmap安装教程用w+r打开(sqlyog安装步骤)

    sqlmap安装教程需要工具:sqlmap、python2或3、计算机自带的CMD一、工具安装1、自行上官网安装sqlmap、python2或32、首先安装python可以无脑点继续,但是在下图的安装选项中,最后一个选项涉及后期环境搭建,可以选择安装,也可以不安,后期手动添加3、将安装的sqlmap文件夹打开并固定一个名字(SQLMap)4、将SQLMap打开会发现有一个很长串的文件夹,点开并将里面的文件全部剪切到SQLMap这个文件的目录下5、将SQLMap文件夹放入已安装好的pytho

    2022年4月18日
  • 在线难例挖掘(OHEM)[通俗易懂]

    在线难例挖掘(OHEM)[通俗易懂]OHEM(onlinehardexampleminiing)详细解读一下OHEM的实现代码:defohem_loss(batch_size,cls_pred,cls_target,loc_pred,loc_target,smooth_l1_sigma=1.0):”””Arguments:batch_size(int):…

    2022年5月30日
  • ospf数据库同步过程_OSPF的概念

    ospf数据库同步过程_OSPF的概念OSPF协议之链路数据库同步OSPF如何实现链路状态数据库的同步-链路信息主要包括:1、链路的类型;2、接口IP地址及掩码;3、链路上所连接的邻居路由器;4、链路的带宽(开销)。区别于RIP路由器之间交互的路由信息,OSPF路由器同步的是最原始的链路状态信息,而且对于邻居路由器发来的链路状态信息,仅作转发。最终所有路由器都将拥有一份相同且完整的原始链路状态信息。为…

    2022年10月15日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号