Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Teensy 3.2 bitband?

  1. #1
    Junior Member
    Join Date
    Jan 2020
    Location
    New York City
    Posts
    4

    Teensy 3.2 bitband?

    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?

  2. #2
    Junior Member
    Join Date
    Jan 2020
    Location
    New York City
    Posts
    4
    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.

  3. #3
    Senior Member
    Join Date
    Mar 2017
    Location
    Oakland, CA, USA
    Posts
    169
    Here’s some code I’ve been playing with to be a nice API for accessing bit-band regions, but also compile down to minimal instructions:
    https://forum.pjrc.com/threads/58965...cess-functions

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •