2017-11-05 03:04 AM
I am trying to configure MPU in STM32F103RB using ARM Information Center. It says there that '
The base address must be aligned to the size of the region. For example, a 64KB region must be aligned on a multiple of 64KB, for example, at
0x00010000
or
0x00020000
.' Here's a link to that page,
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihjddef.html
.What does this mean?
I want to select a region of 64 bytes starting from 0x20000000. How can I do this?
#stm32-nucleo #memory-protection #stm32f103rbSolved! Go to Solution.
2017-11-05 10:59 AM
You do seem to be creating complication where there is none. It is a test of if an address is valid. The base address needs the order bits to be zero, the range comparator in the processor looks only at the high order bits, so the address provided needs to be suitably aligned.
if ((0x20000000 % 64) == 0)
puts('Address is usable');
else
puts('Address is NOT usable');
So for 64 bytes valid addresses would look like
0x20000000
0x20000040
0x20000080
0x200000C0
0x20000100, etc
If this is unclear perhaps consult with a teacher or tutor who understands binary math and micro-controllers.
More generally
if ((MMURegionAddress % MMURegionSize) == 0)
puts('Address is usable');
else
puts('Address is NOT usable');
2017-11-05 05:43 AM
In the first case
BaseAddr % Size == 0, where Size is a power of two
This would be true for 0x20000000[0x00040] which would mean 0x20000000..0x2000003F
But you could NOT do 0x20002000[0x4000]
2017-11-05 09:12 AM
How do I calculate BaseAddr % SIze?
In my case 64 is 2^6, so how do I calculate,
0x20000000 % 6?
2017-11-05 10:59 AM
You do seem to be creating complication where there is none. It is a test of if an address is valid. The base address needs the order bits to be zero, the range comparator in the processor looks only at the high order bits, so the address provided needs to be suitably aligned.
if ((0x20000000 % 64) == 0)
puts('Address is usable');
else
puts('Address is NOT usable');
So for 64 bytes valid addresses would look like
0x20000000
0x20000040
0x20000080
0x200000C0
0x20000100, etc
If this is unclear perhaps consult with a teacher or tutor who understands binary math and micro-controllers.
More generally
if ((MMURegionAddress % MMURegionSize) == 0)
puts('Address is usable');
else
puts('Address is NOT usable');
2017-11-05 11:58 AM
Thanks