Hi all,
I'm still fairly new to the Teensy and to C in general, so I apologize if this question is a bit rudimentary.
Here's the situation. I have a Teensy 3.2 and an 8 position DIP switch. Because of everything else going on in this project, the first 6 positions are connected to pins 14 through 19 on the Teensy, then the last two are connected to pins 10 and 11. My goal here is to come up with a single 8 bit number.
I could do this via a bunch of individual pin reads, but that seems less elegant. I think that position 1 through 6 line up with PortA 0 through 5. Does that mean I could do something like:
addresstemp = PORTA;
and then mask off the bits I want? The documentation here: https://www.pjrc.com/teensy/pins.html suggests that in input mode the PORTX object controls the internal pull up.
The second part of the question is that I believe the best way to do this in C would be to work things out so that I end up with everything in two registers, aligned correctly, masked off, then OR them together. Does that sound about right?
Thank you!
I'm still fairly new to the Teensy and to C in general, so I apologize if this question is a bit rudimentary.
Here's the situation. I have a Teensy 3.2 and an 8 position DIP switch. Because of everything else going on in this project, the first 6 positions are connected to pins 14 through 19 on the Teensy, then the last two are connected to pins 10 and 11. My goal here is to come up with a single 8 bit number.
I could do this via a bunch of individual pin reads, but that seems less elegant. I think that position 1 through 6 line up with PortA 0 through 5. Does that mean I could do something like:
addresstemp = PORTA;
and then mask off the bits I want? The documentation here: https://www.pjrc.com/teensy/pins.html suggests that in input mode the PORTX object controls the internal pull up.
The second part of the question is that I believe the best way to do this in C would be to work things out so that I end up with everything in two registers, aligned correctly, masked off, then OR them together. Does that sound about right?
Thank you!