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

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

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • hexdump 命令「建议收藏」

    hexdump 命令「建议收藏」大概整明白了-e里边这个format到底怎么写。模仿man里边的命令demo改了一个能用hexdump-e‘”0x%08_ax:”4/4″%08x”“\n”’plt|less搞清楚的含义:%08_ax:08是输出按8个字符的长度输出,高位补0;_a是输出offset;x是按16进制;4/4:第一个4是每行四次输出;第二个4是每次输出4个byte0x00000000:464c457f0001010100000000000000000x00000010:000300

    2022年9月21日
    3
  • 流程引擎标准定义_开源流程引擎

    流程引擎标准定义_开源流程引擎1.1流程定义引擎功能说明管理员无需编程基础便能快捷地定义出符合本单位需求的各项工作流程,协同办公平台流程定义项目丰富,能够规范企业业务流程,发挥企业各种资源及系统的最大效能。流程定义主要包括流程的基本属性、节点定义、相关表单、审核常用语、流程归档。可自定义流程的使用范围,序号一级功能二级功能功能详细需求说明1. 

    2022年10月20日
    1
  • robotium官网[通俗易懂]

    robotium官网[通俗易懂]官网地址:https://code.google.com/p/robotium/

    2022年7月25日
    6
  • JQuery中的bind()和unbind()的理解「建议收藏」

    JQuery中的bind()和unbind()的理解「建议收藏」bind()和unbind()提供了事件的绑定和取消机制,既可以绑定html默认支持的事件,也能够绑定自定义的事件。1、JQuery中事件可以重复绑定,不会覆盖。当点击button1的时候,这2个

    2022年8月2日
    9
  • 微软Office2007专业增强版 集成最新SP3[通俗易懂]

    微软Office2007专业增强版 集成最新SP3[通俗易懂]微软Office2007专业增强版,集成最新SP3补丁包,集成序列号,安装完后自动激活,不仅在功能上进行了优化,而且安全性稳定性更得到了巩固。  MicrosoftOfficeProfessionalPlus2007包括:  MicrosoftOfficeExcel2007  MicrosoftOfficeOutlook2007  MicrosoftOfficePower…

    2022年7月19日
    29
  • 浅析Easyui Datagrid的Rownumber行号显示「建议收藏」

    浅析Easyui Datagrid的Rownumber行号显示「建议收藏」easyuidatagrid如何获取行号getRowIndex方法$(选择器).datagrid(“getRowIndex”,row)+1其中row可以是一行也可以是这一行的id值,获取选择行可以用getselected或getselections方法,行索引从0开始,所以要加1,具体可以参照easyUI的API。Datagrid中当你的行数据超过9999时,第一列的行号r

    2022年5月24日
    120

发表回复

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

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