ARM Cortex-M3/M4 Bit Banding
Keywords: Embedded systems, ARM, Bit Banding
“Bit Banding- A term used in ARM Cortex-M3/M4 architecture to indicate regions in processor memory map where individual bits can be accessed by a unique address.”
One of the major difference between Cortex-M0 and M3/M4 is Bit Banding. In ARM Cortex-M3/M4 memory map, there are 4-regions labeled as bit-band regions and bit-band alias respectively – Figure-1.

As shown in Figure-1, both the SDRAM and Peripheral Regions contain 1MB Bit Band and 32MB Bit Band alias regions. Actually the 1MB Bit Band is the region where individual bits are addressable via 4-byte unique address AND the Bit Band alias is the region within which addresses of individual bits in 1MB Bit Band region lies- Figure-2,3.


1. Why bit-band?
In almost majority of cases, processors can’t access a single bit in memory. In other words there is no such thing as “BSET” (bit-set) instruction. Normally when there is a requirement of bit manipulation, processor has to go through the Read-Modify-Write cycle i.e. a whole word (4-byte in case of 32-bit system) is fetched, target bit is modified by shift and logical operation like OR, AND, NOT, XOR etc., and finally the whole “WORD” is written back to memory. Sample macros for standard bit operations are given bellow.
/* bit operations macros */ #define __setbit(___reg, ___bit) ((___reg) |= (1U << (___bit))) #define __clearbit(___reg, ___bit) ((___reg) &= (~(1U << (___bit)))) #define __togglebit(___reg, ___bit) ((___reg) ^= (1U << (___bit))) #define __getbit(___reg, ___bit) (((___reg) & (1U << (___bit))) == (1U << (___bit)))
The read-modify-write operation is indeed an expensive operation which may cause some unwanted results especially in a multi threaded environment where multiple threads are performing operations on target memory contents.
Bit banding has the benefit of targeting single bit without any expensive (execution wise) operation like shift etc. This helps minimizing read-modify-write overhead.
Consider an example of GPIOs. Let say we want to toggle a specific GPIO pin at the rate of let say 5Mhz. This means each time we have to fetch respective GPIO pin Value register contents, toggle the target bit and write back to the GPIO value/data register. i.e.
GPIO_VAL_REG ^= (1U << ___gpPin); /* or */ GPIO_VAL_REG = GPIO_VAL_REG ^ (1U << ___gpPin);
The above operation is performed non-atomically as:

Now let say the GPIO_VAL_REG register is in bit band region; it means each bit can be accessed individually by a unique address in subsequent bit-band alias region.

In this case if we want to set/reset any of GPIO bit, all we have to do is to write (0,1) to respective bit associated memory address and the SOC will automatically perform the operation of specific bit atomically.
/* Set */ *(volatile unsigned int *)ADDRESS = 1; /* Reset */ *(volatile unsigned int *)ADDRESS = 0;
2. Address Calculation:
Now that we have explained Bit-banding in ARM Cortex-M3/M4, let see how we can calculate address (in bit-band alias) of a single bit in bit-band region. The formula for address calculation is given bellow.
Address: Bit Band Alias Region Base Address + (byte offset from bit band region x 32 ) + (bit number x 4 )
Let’s say as an example, we want to calculate the bit address of 4th bit in SRAM 2nd byte of bit-band region. In this case:
Alias Base Address: 0x22000000
Byte Offset: 2 (from bit-band region 0x20000000)
Bit No: 3 (4th bit)
Address: 0x22000000 + (2 x 32 ) + (3 x 4)
Address: 0x2200004C
And subsequently:
/* Set */ (*(volatile unsigned int *)0x2200004C) = 1; /* Reset */ (*(volatile unsigned int *)0x2200004C) = 0;
References:
[1] – ARM Cortex-M3/M4 Reference Manual
[1] – Bit-banding – An Elegant Approach to Setting & Clearing Bits
Hey very nice blog! asmr 0mniartist
My partner and I absolutely love your blog and find almost all of your post’s to
be just what I’m looking for. Does one offer guest
writers to write content to suit your needs?
I wouldn’t mind publishing a post or elaborating on some
of the subjects you write with regards to here. Again, awesome web site!
0mniartist asmr
Great article. I will be experiencing a few of these issues as well..
0mniartist asmr
This design is incredible! You definitely know how to keep a
reader amused. Between your wit and your videos, I was almost moved to start my
own blog (well, almost…HaHa!) Great job. I really loved what you had to
say, and more than that, how you presented it. Too
cool! 0mniartist asmr
Pretty! This has been an extremely wonderful article.
Thank you for supplying these details. 0mniartist asmr
It’s going to be end of mine day, however before finish I am reading this fantastic piece of
writing to improve my know-how.
Appreciate this post. Let me try it out.
Aw, this was a really nice post. Spending some time and
actual effort to generate a really good article… but what can I
say… I procrastinate a whole lot and never manage to get anything done.
Howdy! I understand this is kind of off-topic but I needed to ask.
Does managing a well-established website such as yours take a massive amount work?
I’m brand new to operating a blog but I do write in my diary daily.
I’d like to start a blog so I can easily share my
own experience and thoughts online. Please let me know if you have any kind of suggestions or tips for brand new aspiring blog owners.
Appreciate it!
Hi, this weekend is nice in support of me, as this point
in time i am reading this great educational paragraph here at
my house.
You need to be a part of a contest for one of the
greatest blogs on the net. I most certainly will highly recommend this site!
This is my first time pay a quick visit at here and i am in fact
pleassant to read everthing at alone place.
Hi there, I discovered your site by way of Google whilst searching
for a related matter, your web site came up, it appears to be like good.
I have bookmarked it in my google bookmarks.
Hello there, just changed into alert to your blog thru Google, and found that it’s really informative.
I’m gonna watch out for brussels. I’ll be grateful if you happen to proceed this in future.
A lot of folks might be benefited out of your writing.
Cheers!
At this time it looks like Movable Type is the best blogging platform
out there right now. (from what I’ve read) Is that what you’re using on your blog?
scoliosis
It’s a shame you don’t have a donate button! I’d definitely
donate to this outstanding blog! I suppose for
now i’ll settle for book-marking and adding your RSS feed
to my Google account. I look forward to new updates and will
talk about this blog with my Facebook group. Chat soon! scoliosis
scoliosis
Hi I am so delighted I found your web site, I
really found you by accident, while I was looking on Google for something else, Nonetheless I am here now and would
just like to say many thanks for a incredible post and a all round thrilling blog (I also love the theme/design), I don’t have time to browse it all
at the minute but I have bookmarked it and also included your RSS feeds, so when I have
time I will be back to read much more, Please do keep up
the superb jo. scoliosis
free dating sites
Hello just wanted to give you a quick heads up. The text in your
post seem to be running off the screen in Internet explorer.
I’m not sure if this is a format issue or something to do with browser compatibility but I thought
I’d post to let you know. The layout look great
though! Hope you get the issue resolved soon. Many thanks dating
sites https://785days.tumblr.com/
free dating sites
Pretty nice post. I just stumbled upon your blog and wanted to mention that I’ve really loved surfing around
your blog posts. After all I’ll be subscribing to your feed
and I hope you write once more very soon! dating sites
I every time emailed this web site post page to all
my contacts, since if like to read it next my contacts will too.
I have been exploring for a bit for any high-quality articles
or weblog posts on this kind of area . Exploring
in Yahoo I ultimately stumbled upon this web site.
Studying this information So i’m satisfied to exhibit
that I have an incredibly good uncanny feeling I discovered just what I needed.
I most unquestionably will make sure to do not fail to remember this website and provides it a glance on a continuing basis.
I was wondering if you ever considered changing the structure of your blog?
Its very well written; I love what youve got to say. But maybe you
could a little more in the way of content so people could
connect with it better. Youve got an awful lot of text for only
having one or 2 pictures. Maybe you could space it out better?
Remarkable! Its in fact amazing post, I have got much
clear idea on the topic of from this piece of writing.
A person essentially lend a hand to make severely posts
I might state. This is the very first time I frequented your web page and to this point?
I surprised with the research you made to create this
actual post amazing. Wonderful task!
My brother recommended I might like this blog. He was entirely right.
This post actually made my day. You cann’t believe simply
how so much time I had spent for this information! Thanks!
Appreciate this post. Let me try it out.
Hbcu Colleges For Nursing Kindle For Mac Read Epub
My site; library
Biology Letters Supplementary Material Sing Unburied Sing Essay
My web site :: pdf wordpress (innovation.cccb.org)
Hey There. I discovered your weblog using msn. This is a really
smartly written article. I’ll make sure to bookmark it and return to read more of your
useful info. Thank you for the post. I’ll certainly return.
I have read so many posts regarding the blogger lovers except this post is actually a nice piece of writing, keep it up.
Good day very nice web site!! Man .. Beautiful .. Wonderful ..
I’ll bookmark your website and take the feeds additionally?
I am satisfied to search out so many helpful information right here in the put up, we’d like
develop more strategies on this regard, thanks for sharing.
. . . . .
Howdy, There’s no doubt that your site may be having browser compatibility
issues. When I look at your site in Safari, it looks
fine but when opening in I.E., it has some overlapping issues.
I simply wanted to give you a quick heads up! Besides that, fantastic site!
você possui outros posts que tratem este assunto de forma mais profunda
?
Hi there, I discovered your website by means of
Google at the same time as looking for a similar matter, your web site came up, it appears good.
I’ve bookmarked it in my google bookmarks.
Hi there, just was alert to your blog thru Google, and found that it is truly informative.
I’m going to watch out for brussels. I will appreciate for those who proceed
this in future. A lot of other folks can be benefited out of
your writing. Cheers!
This blog was… how do I say it? Relevant!! Finally I have found something
which helped me. Thank you!
What’s Taking place i’m new to this, I stumbled upon this I have found It absolutely helpful and it
has aided me out loads. I am hoping to give a
contribution & help different users like its helped me.
Great job.
Thanks designed for sharing such a nice thinking, article is nice, thats why i have read it entirely
Hi there just wanted to give you a quick heads up. The words in your
article seem to be running off the screen in Opera.
I’m not sure if this is a format issue or something to
do with browser compatibility but I figured I’d post to let you know.
The design look great though! Hope you get the issue solved soon. Cheers
I am regular reader, how are you everybody?
This post posted at this web page is actually fastidious.
This is the perfect webpage for anybody who wants
to understand this topic. You understand a whole lot its almost tough to argue with you (not that I really will need
to…HaHa). You certainly put a brand new spin on a subject which has been discussed for decades.
Excellent stuff, just wonderful!
whoah this weblog is great i like reading your articles.
Stay up the great work! You know, lots of persons are looking round for this info, you can help them greatly.
We are a group of volunteers and starting a new scheme in our
community. Your web site offered us with valuable information to work on. You
have done a formidable job and our entire community will be grateful to
you.
Does your blog have a contact page? I’m having problems locating
it but, I’d like to send you an e-mail. I’ve got some suggestions for your blog you might
be interested in hearing. Either way, great blog and I look forward to seeing it expand
over time.
Hey just wanted to give you a quick heads up. The text in your post seem
to be running off the screen in Ie. I’m not sure if this is a format issue or something to
do with internet browser compatibility but I figured I’d post to let you
know. The design look great though! Hope you get the problem solved
soon. Cheers
Hi, Neat post. There is a problem with your site in internet explorer, would check this?
IE nonetheless is the market chief and a large section of other people will
pass over your excellent writing due to this problem.
Since the admin of this website is working, no hesitation very shortly it will be well-known, due to its
feature contents.
Pretty nice post. I just stumbled upon your weblog and wished to
say that I have really enjoyed browsing your blog posts.
In any case I’ll be subscribing to your feed and I hope you write again very soon!
I love reading through a post that can make men and women think.
Also, thank you for allowing me to comment!
Awesome things here. I’m very glad to see your post. Thanks a
lot and I am looking forward to contact you. Will you kindly drop me a
e-mail?
Helpful info. Lucky me I found your website by accident,
and I am shocked why this accident did not took place earlier!
I bookmarked it.
wonderful publish, very informative. I ponder why the opposite
specialists of this sector don’t notice this.
You should continue your writing. I’m sure, you have a huge readers’ base
already!
Now I am going to do my breakfast, once having my breakfast coming again to read other news.
Wоw, this article is pleasant, mу sister is anaⅼyzing
these things, so I am going to tell her.
Howdy! I simply wish to offer you a big thumbs up for your
great information you have here on this post.
I’ll be returning to your web site for more soon.
Thanks for sharing your thoughts on are.
Regards
Pretty nice post. I simply stumbled upon your
blog and wanted to mention that I have truly enjoyed surfing around your blog posts.
In any case I’ll be subscribing to your feed and I’m hoping
you write again very soon!
What’s up i am kavin, its my first time to commenting anywhere,
when i read this article i thought i could also make comment due to
this brilliant post.
What’s up i am kavin, its my first occasion to commenting anyplace, when i read this post i thought i could also
create comment due to this sensible paragraph.
Do you have a spam issue on this website; I also am a blogger, and I was
wanting to know your situation; many of us have developed some nice
methods and we are looking to trade methods with others, be sure to shoot me an e-mail if interested.
Write more, thats all I have to say. Literally, it seems as though you relied on the video
to make your point. You clearly know what youre talking about, why throw away your intelligence on just posting videos to your weblog
when you could be giving us something enlightening to read?
Excellent post. I was checking continuously this blog and I’m impressed!
Very helpful info specially the last part 🙂 I care for such information much.
I was looking for this particular information for a very long time.
Thank you and best of luck.
Simply wish to say your article is as surprising. The clarity in your
post is just spectacular and i can assume you are an expert
on this subject. Well with your permission let me to grab your RSS feed to
keep up to date with forthcoming post. Thanks a million and please keep up the enjoyable work.
Hello there, You have done an incredible job. I’ll certainly digg it and personally recommend to my friends.
I’m sure they will be benefited from this site.
Hey there, You have done an incredible job. I will definitely digg it and personally recommend to my
friends. I am confident they’ll be benefited from this website.
If some one wishes expert view about running a blog afterward
i recommend him/her to pay a visit this blog, Keep up the pleasant
job.
Good web site! I really love how it is easy on my eyes and the data are well written. I’m wondering how I might be notified when a new post has been made. I’ve subscribed to your feed which must do the trick! Have a nice day!
Since the admin of this web site is working, no question very soon it
will be famous, due to its feature contents.
It’s remarkable designed for me to have a web site, which is helpful in support of my knowledge.
thanks admin
Saved as a favorite, I like your website!
wonderful post, very informative. I ponder
why the other experts of this sector don’t realize this.
You must proceed your writing. I’m confident, you have a great readers’
base already!
Very good post! We will be linking to this great content on our site.
Keep up the great writing.
Good info. Lucky me I found your site by accident (stumbleupon).
I’ve saved as a favorite for later!
Thanks for another wonderful post. Where else
may anybody get that type of information in such a perfect method of writing?
I’ve a presentation subsequent week, and I am at the
search for such information.
Wow! At last I got a blog from where I know how to really obtain useful
information regarding my study and knowledge.
Greetings! Very helpful advice within this article! It’s the
little changes that make the most important changes.
Many thanks for sharing!
Hey very nice blog!
Simply wish to say your article is as amazing.
The clarity in your post is just cool and i could assume you’re an expert on this subject.
Fine with your permission let me to grab your feed to keep updated with forthcoming
post. Thanks a million and please keep up the gratifying
work.
Hi! This is kind of off topic but I need some advice from an established blog.
Is it tough to set up your own blog? I’m not very techincal but I can figure things out pretty fast.
I’m thinking about creating my own but I’m not sure where to start.
Do you have any points or suggestions? Appreciate it asmr https://app.gumroad.com/asmr2021/p/best-asmr-online asmr
Undeniably believe that which you stated. Your favorite justification seemed to be on the internet the easiest thing to be aware of.
I say to you, I definitely get irked while people consider worries that they just don’t know
about. You managed to hit the nail upon the top
and also defined out the whole thing without having side-effects , people could take a signal.
Will probably be back to get more. Thanks scoliosis surgery https://0401mm.tumblr.com/ scoliosis surgery
Hey There. I discovered your weblog the use of msn. That is a really smartly written article.
I will make sure to bookmark it and come back to learn extra
of your useful info. Thank you for the post. I will definitely comeback.
quest bars http://bit.ly/3jZgEA2 quest bars
This info is worth everyone’s attention. Where can I find out more?
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery
Heya i am for the first time here. I came across this board and I find It
truly useful & it helped me out a lot. I hope to give something back and aid others like
you helped me. ps4 https://j.mp/3nkdKIi ps4
Hello everybody, here every person is sharing these kinds of experience, therefore it’s fastidious to
read this web site, and I used to visit this web site all the time.
quest bars https://www.iherb.com/search?kw=quest%20bars quest
bars
It’s appropriate time to make some plans for the future and it’s time to be happy. I have read this post and if I could I want to suggest you few interesting things or tips. Maybe you could write next articles referring to this article. I wish to read more things about it!
constantly i used to read smaller content that as well clear their motive, and that is also
happening with this paragraph which I am reading now. cheap flights http://1704milesapart.tumblr.com/ cheap flights
I simply needed to thank you very much yet again. I am not sure what I might have done without the entire tricks contributed by you concerning this topic. Entirely was the traumatic situation in my circumstances, however , being able to see a new well-written tactic you dealt with that forced me to jump for joy. I will be happier for your work as well as believe you know what an amazing job your are accomplishing educating people today through the use of a site. Most likely you have never come across all of us.
This really answered my problem, thank you!
An interesting discussion is worth comment. I think that you should write more on this topic, it might not be a taboo subject but generally people are not enough to speak on such topics. To the next. Cheers
Spot on with this write-up, I truly think this website needs much more consideration. I?ll probably be again to read much more, thanks for that info.
Would you be interested in exchanging links?
Nice post. I learn something more challenging on different blogs everyday. It will always be stimulating to read content from other writers and practice a little something from their store. I?d prefer to use some with the content on my blog whether you don?t mind. Natually I?ll give you a link on your web blog. Thanks for sharing.
I am often to blogging and i really appreciate your content. The article has really peaks my interest. I am going to bookmark your site and keep checking for new information.
Excellent post. Keep posting such kind of information on your site.
Im really impressed by your site.
Hello there, You have done a fantastic job. I will definitely digg it and in my view suggest to my friends.
I’m confident they will be benefited from this website.
Fantastic material. Many thanks! how to write a literary essay need help with essay
Great blog article.Much thanks again. Really Great.
It’s hard to seek out educated folks on this topic, but you sound like you already know what you’re talking about! Thanks
I do not even understand how I finished up right here, but I thought this submit used to be great. I do not understand who you might be but definitely you are going to a famous blogger if you happen to are not already 😉 Cheers!
Thanks for a marvelous posting! I genuinely enjoyed reading it, you’re a great author.I will make sure to bookmark your blog and will eventually come back very soon. I want to encourage that you continue your great work, have a nice day!
I would like to thnkx for the efforts you have put in writing this blog. I am hoping the same high-grade site post from you in the upcoming as well. In fact your creative writing skills has inspired me to get my own web site now. Really the blogging is spreading its wings quickly. Your write up is a good example of it.
What i do not understood is actually how you’re not actually much more well-liked than you might be now. You are so intelligent. You realize therefore significantly relating to this subject, made me personally consider it from numerous varied angles. Its like women and men aren’t fascinated unless it’s one thing to do with Lady gaga! Your own stuffs nice. Always maintain it up!
Howdy just wanted to give you a quick heads up. The text in your content seem to be running off the screen in Chrome. I’m not sure if this is a formatting issue or something to do with web browser compatibility but I figured I’d post to let you know. The style and design look great though! Hope you get the problem fixed soon. Cheers
Oh my goodness! a tremendous article dude. Thanks However I’m experiencing concern with ur rss . Don’t know why Unable to subscribe to it. Is there anybody getting identical rss downside? Anybody who knows kindly respond. Thnkx
I actually wanted to jot down a small note to thank you for some of the fabulous ways you are giving out here. My incredibly long internet research has at the end of the day been paid with reliable suggestions to write about with my companions. I ‘d believe that most of us site visitors actually are very endowed to be in a good network with very many wonderful professionals with good concepts. I feel rather blessed to have encountered your web page and look forward to plenty of more fabulous times reading here. Thanks once more for everything.