Teensy 3.2 bitband?

Status
Not open for further replies.

spolsky

Member
Can anyone point me to a simple code example of bitbanding that works on Teensy 3.2?

I tried this:

Code:
    uint8_t st = 0xAA;
    dbgprintf("Address of byte on stack: %x\n", &st);               // PRINTS 0x20007FD7
    uint8_t* bb = &st + 0x2000000;                                  
    dbgprintf("Address of byte in bitband region: %x\n", bb);       // PRINTS 0x22007FD7
    
    dbgprintf("%d %x %x %x %x %x %x %x %x\n", st, bb[0],            // PRINTS 0 1 0 0 0 1 0 0
        bb[1],                                                      // (expected 1 0 1 0 1 0 1 0)
        bb[2], 
        bb[3], 
        bb[4], 
        bb[5], 
        bb[6], 
        bb[7]
    );

Am I missing something about what I need to do to get bitbanding to work, or is the address map different than I thought?
 
Arg, never mind, I figured it out ... my pointer arithmetic is all wrong, since each bit is mapped to 32 bits in the bitband region.
 
Status
Not open for further replies.
Back
Top