cancel
Showing results for 
Search instead for 
Did you mean: 

Bit-banding Alternatives for Modern ARM Cores

Komal_Y
Associate

Bit-banding Alternatives for Modern ARM Cores

Background Information:

The bit-banding feature available in ARM Cortex-M cores (ARMv7-M architecture including Cortex-M3 and Cortex-M4) provides hardware-level mapping of individual bits within a 1 MB memory region to words in a 32 MB alias region. This mechanism enables atomic bit manipulation without requiring read-modify-write operations.

 

Specific Query:

For ARM Cortex cores beyond M7 architecture that do not support the bit-banding feature, could you please provide detailed information regarding:

 

  • Available alternative methods for atomic bit manipulation
  • Performance implications of these alternatives
  • Recommended implementation strategies for maintaining atomic operations
  • Code examples demonstrating these alternative approaches
  • Request for Documentation
2 REPLIES 2
mƎALLEm
ST Employee

Hello,

Indeed bit-banding is not available on Cortex-M7. According to ARM community from this post, the reason is the following:

mALLEm_0-1762849836841.png

Regarding an available alternative, I think the only solution is to use CMSIS:

void atomic_set_bit(volatile uint32_t *addr, uint32_t bit) {
    uint32_t old, status;
    do {
        old = __LDREXW(addr);
        old |= (1U << bit);
        status = __STREXW(old, addr);
    } while (status != 0);
}

Use __LDREXW/__STREXW for 32-bit, __LDREXH/__STREXH for 16-bit, and __LDREXB/__STREXB for 8-bit operations.

I don't think there is specific documentation regarding this subject

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Andrew Neil
Super User

@Komal_Y wrote:
  • Available alternative methods for atomic bit manipulation

Check if your particular chip has a register (or registers) to give atomic bit manipulation; eg,

AndrewNeil_0-1762858326607.png

That's for STM32H723/733, STM32H725/735 and STM32H730:

https://www.st.com/resource/en/reference_manual/rm0468-stm32h723733-stm32h725735-and-stm32h730-value-line-advanced-armbased-32bit-mcus-stmicroelectronics.pdf#page=521

 

PS:

You'll probably find that HAL uses this - it certainly does for F0.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.