Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Bit-banding maps a complete word of memory onto a single bit in the bit-band region. For example, writing to one of the alias words sets or clears the corresponding bit in the bit-band region. This enables every individual bit in the bit-banding region to be directly accessible from a word-aligned address using a single LDR instruction. It also enables individual bits to be toggled without performing a read-modify-write sequence of instructions.

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
 
  • Like
Reactions: gafsos

    gafsos

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top