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


相关推荐

  • error at hooking api ntprotect_read,match and write

    error at hooking api ntprotect_read,match and write 编译环境:delphi2010+windows7u,用途读取其他程序中readprocessmemory和writeprocessmemory的参数,但不知读取偏移即a+($b),b是怎么读的  一、用hook全局钩子线程钩子:已实现使用INLINEhookapi,CriticalSection临界区,dll分为动态loadlibry和静态加载问题1:对多线程目标

    2022年9月12日
    0
  • Linux内核有没有rootfs,Linux内核rootfs的初始化过程[通俗易懂]

    Linux内核有没有rootfs,Linux内核rootfs的初始化过程[通俗易懂]由于在下水平相当有限,不当之处,还望大家批评指正^_^在Linuxshell中执行mount命令,通常可以看到某个做了文件系统的磁盘分区或flash分区或内存文件系统做为所谓的根文件系统被mount到了挂载点/处。实际上内核中最初始的根文件系统,并不是来自内核外部,他是由内核自己构建出来的。为了说明这个过程,我们先说说mount的过程。系统调用sys_mount是在fs/namespace.c…

    2022年9月28日
    0
  • J2ME开发站点资源「建议收藏」

    J2ME开发站点资源「建议收藏」英文站点,英文好的开发者应该收藏的站点。SUNJ2MEWebSite:http://java.sun.com/j2me/诺基亚开发论坛:http://discussion.forum.nokia.com/forum/IBMalphaworks:http://alphaworks.ibm.com/wirelessIBM新兴技术资源网站,这里有各种最新的技术,当然也有非常丰富的J2ME开发资

    2022年7月27日
    3
  • RUST开服教程、常用指令及心得[通俗易懂]

    RUST开服教程、常用指令及心得[通俗易懂]【前言】【开始前你需要了解的事情】①常用网址②更新与删档日期③目前国服环境【服务器硬件的选择】【标准服务器】①下载和更新服务器②制作服务器的启动脚本③选择你的服务器地图④运行服务器【模组服务器】①完成标准服务器的下载和设置②安装Oxide插件平台③下载插件④安装插件⑤调试插件⑥模组服的更新⑦在标准服中使用插件功能【在自己的电脑上运行服务端】①…

    2022年7月14日
    74
  • jquery定时执行函数_jquery自动提交

    jquery定时执行函数_jquery自动提交setTimeout用于延时器,只执行一次.setInterval:用于多次执行.functiongetnums(){$.get(“http://special.ku6.com/office2010/api/nums.php?”+Math.random(),function(data){nums=”;$.each(data,f

    2022年9月12日
    0
  • K8S状态为evicted

    K8S状态为evicted报错:xxisEvictedonxx主机查询找出Evicted状态节点kubectlgetpods|grepEvicted删除节点,自动重启kubectldeletepod$podName也可以通过脚本定时执行kubectlgetpods|grepEvicted|awk'{print$1}’|xargskubectldeletepodxargs是给命令传递参数的一个过滤器,可以将管道或标准输入的数据转换成参数原因

    2022年5月17日
    120

发表回复

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

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