0% found this document useful (0 votes)
43 views7 pages

Bit Banding Example

This document provides an example of using bit banding to set an enable bit of a Timer32 peripheral. It explains that the bit band offset is located at 0x4200 0000 and gives the peripheral offset of Timer32 at 0xC000. It then shows how to calculate the specific bit-banded address for the enable bit by using the register offset of 0x08 and bit offset of 0x07. Finally, it demonstrates two solutions for setting the enable bit - using a pointer to the address or defining an alias to the address.

Uploaded by

yogi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views7 pages

Bit Banding Example

This document provides an example of using bit banding to set an enable bit of a Timer32 peripheral. It explains that the bit band offset is located at 0x4200 0000 and gives the peripheral offset of Timer32 at 0xC000. It then shows how to calculate the specific bit-banded address for the enable bit by using the register offset of 0x08 and bit offset of 0x07. Finally, it demonstrates two solutions for setting the enable bit - using a pointer to the address or defining an alias to the address.

Uploaded by

yogi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Bit Banding Example

Last updated 6/18/18


Bit Banding Example
Set the Timer32 enable bit using bit-banding

Bit Band offset – 0x4200 000

Common – last updated 6/18/18 2 © tj


Bit Banding Example
Set the Timer32 enable bit using bit-banding

Peripheral (Timer32) offset


- 0xC000

Common – last updated 6/18/18 3 © tj


Bit Banding Example
Set the Timer32 enable bit using bit-banding
Register offset – 0x08

Common – last updated 6/18/18 4 © tj


Bit Banding Example
Set the Timer32 enable bit using bit-banding
Bit offset – 0x07

Common – last updated 6/18/18 5 © tj


Bit Banding Example
Set the Timer32 enable bit using bit-banding
each byte address needs to allow
// Peripheral base address is 0x4000 0000 for 8 bits * 4 bytes = 32 bit-band-bytes
// Peripheral bit band base address is 0x4200 0000
// Timer32 offset is 0xC000
// Register offset is 0x08
// bit offset is 4bytes * bit# = 0x04 * 7 = 0x1C

// Bitband alias --> 0x4200 0000 + 0x20*0xC000 + 0x20*0x08 + 0x1C = 0x4218 011C

//Solution 1 //Solution 2
// //
// Define a pointer to use to access memory // Define an alias to use to access memory
volatile uint8_t * T32_en_ptr; #define T32_en (*((volatile uint8_t *)(0x4218011C)))
T32_en_ptr = (volatile uint8_t *)(0x4218011C); // need to cast the integer
// set the initial value for the output
// set the initial value for the output T32_en = 0;
*T32_en_ptr = 0;
T32_en = 1;
*T32_en_ptr = 1;
T32_en = 0;
*T32_en_ptr = 0;
Cast the value as a pointer to an 8 bit int because the processor ignores
Common – last updated 6/18/18 all bits but bit0 on writes,
6 and returns 1 byte of either 0x00 or 0x01 on reads © tj
Bit Banding Example
Set the Timer32 enable bit using bit-banding
Debug – single step

Common – last updated 6/18/18 7 © tj

You might also like