Nothing Special   »   [go: up one dir, main page]

Bit Banding Example

Download as pdf or txt
Download as pdf or txt
You are on page 1of 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