STM32L152 Bit Banding

Status
Not open for further replies.

gafsos

Full Member level 3
Joined
Feb 1, 2006
Messages
189
Helped
25
Reputation
50
Reaction score
11
Trophy points
1,298
Location
North Africa
Activity points
2,450
Hello

I'm working on STM32 example that shows how to use CortexM3 Bit-Band access, This is a part of the code, But it is not understandable, can you please help me it is very urgent,

thank you

#define RAM_BASE 0x20000000
#define RAM_BB_BASE 0x22000000

/* Private macro -------------------------------------------------------------*/
#define Var_ResetBit_BB(VarAddr, BitNumber) \
(*(__IO uint32_t *) (RAM_BB_BASE | ((VarAddr - RAM_BASE) << 5) | ((BitNumber) << 2)) = 0)

#define Var_SetBit_BB(VarAddr, BitNumber) \
(*(__IO uint32_t *) (RAM_BB_BASE | ((VarAddr - RAM_BASE) << 5) | ((BitNumber) << 2)) = 1)

#define Var_GetBit_BB(VarAddr, BitNumber) \
(*(__IO uint32_t *) (RAM_BB_BASE | ((VarAddr - RAM_BASE) << 5) | ((BitNumber) << 2)))
 

Also, is there an advantage to using the bit band region to access peripheral registers over some sort of direct access?
 

I have only used some ARM9 mcu so I'm not familiar with Cortex M3 or bit banding.

According to the technical reference manual of the link in the previous post


so I assume it is the fastest way.

You can also download the The Insider's Guide To The STM32 ARM Based Microcontroller
in page 21 section 2.3.7 it has some info about bit banding

Alex
 
Reactions: gafsos

    gafsos

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…