I wonder to know is there anyone who define a variable in bit-band area in c programming language for cortex-M3.
I have followed the compiler attribute based on the below link www.keil.com/.../armcc_chr1359124215827.htm but when I check the address range, it has been defined out of the scope of bit-banding and it seems the attribute doesn't effect the code even if I use this code __attribute__((at())) ?
As far as I know bit-banded area map each bit into 8 bit if we write 0b00000001 into the 8 bit the corresponding bit become one and vice versa but what I want to know is, it has been said that bit-banded area help us to toggle bit in a atomic way (what I'm looking for) ,how could be accomplished !?
Are you sure you have done everything correctly?
No
Note that there are two regions associated with every bit-band range.
I knew and considered that in my project
Have you got any simple sample that worked for you and you have checked it before?
Thanks
"I knew and considered that in my project"
You considered it? It's not optional if you want to use the bit-banding feature. The memory controller will only give you this additional "magic" if you do place your "int" variables in the 32 MB memory range - then accesses to the int will alias to a specific bit in the 1MB address range.
"Have you got any simple sample that worked for you and you have checked it before?"
Why does it sound like you don't believe it will work? The compiler or language need not know anything about this magic since it's part of the hardware. The only important thing is that there is aliasing between the bits and the integers - so it's important to use "volatile" to make sure the compiler doesn't cache values. The only potential tool issues is that the debugger might not know about this alias functionality.
For testing, it's enough for you to compute the alias address of a specific bit and then just use a int pointer that points to this aliased address. Suddenly you can toggle a specific I/O pin with an assign to the pointer. Trivial to test. The user manual very clearly describes the formula for computing the alias address. But the formula is so trivial you don't need it - you can figure it out yourself if you just know the base address of the bit range and the int range.
It's by reading the documentation you learn. Not by having someone else post "magic" code that you just reuse.
So in the end - if it hasn't worked for you, then you have placed the data at the wrong address. And the map file is excellent for verify the location of variables. Or you might have forgotten "volatile".
"with an assign to the pointer" should of course be "with an assign through the pointer"
This forum should do well to use a standard implementation with real accounts and edit functionality.
Thanks per you are right but I wanted to make sure about the IDE attribute that it works or not. Thanks for your time
What IDE attribute?