This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Bit-banding in SRAM region (Cortex-M4)

Hi.

I would like to use bit-banding feature in SRAM, but don't know exactly how to implement it with C. I already use bit-banding in peripheral region with this kind of macro:

#define BITBAND_PERI_REF        0x40000000

#define BITBAND_PERI_BASE     0x42000000

#define BITBAND_PERI(a,b)         ((BITBAND_PERI_BASE + (a - BITBAND_PERI_REF) * 32 + (b * 4)))

But I am confused how to connect bit-banding with some random word (half-word or byte) in SRAM, where separate bits could represent some statuses.

Thank you for your help.

Parents
  • Hi,

    STM32 M4 as well as Freescale/NXP Kinetis M4 cores have RAM bitband alias region located at 0x22000000

    Writing an analog macro for SRAM is possible:

    #define BITBAND_SRAM_REF        0x20000000

    #define BITBAND_SRAM_BASE     0x22000000

    #define BITBAND_SRAM(a,b)         ((BITBAND_SRAM_BASE + (a - BITBAND_SRAM_REF) * 32 + (b * 4)))

    Personally, I use the following macro to access both Peripheral and RAM bitband regions:

    #define BITBAND_REGION_BIT(src_byte_addr, bit)  (((((uint32_t)(src_byte_addr) & 0x000fffff) << 5) | ((uint32_t)(src_byte_addr) & 0xfff00000) | 0x02000000) + (((uint32_t)(bit)) << 2))
    
Reply
  • Hi,

    STM32 M4 as well as Freescale/NXP Kinetis M4 cores have RAM bitband alias region located at 0x22000000

    Writing an analog macro for SRAM is possible:

    #define BITBAND_SRAM_REF        0x20000000

    #define BITBAND_SRAM_BASE     0x22000000

    #define BITBAND_SRAM(a,b)         ((BITBAND_SRAM_BASE + (a - BITBAND_SRAM_REF) * 32 + (b * 4)))

    Personally, I use the following macro to access both Peripheral and RAM bitband regions:

    #define BITBAND_REGION_BIT(src_byte_addr, bit)  (((((uint32_t)(src_byte_addr) & 0x000fffff) << 5) | ((uint32_t)(src_byte_addr) & 0xfff00000) | 0x02000000) + (((uint32_t)(bit)) << 2))
    
Children