I've sort of bumbled onto the fact that unless I use pinMode() at least once, my direct port manipulation code doesn't work.
So for example, I've got code like
that in theory ought to turn the bottom 8 pins of port C to INPUT mode, but unless I've run pinMode() invocations (either INPUT or OUTPUT), it doesn't seem to do anything.
I'm guessing there's something under the covers that pinMode() does that I'm unfamiliar with. While I tried to dig into pinMode()'s code to figure out what's going on, it's a rather complex block of code, and I'm not quite following what it's doing.
Is there a *canonical* description (or better yet, code example) of how to do direct port manipulation (both input and output) on Teensy 3.6 somewhere? I read the MK66FX1M0 chip documentation, but it's a bit overwhelming as well, or at least it's not obvious to me how I turn the descriptions there into working C code.
Also, if I've got a function I want to call say 40 times a second (25 mS intervals), and I've also got a bunch of input pin driven interrupts, what's the best way to set up the code so they don't interfere with each other? That is to say, I need both the clock driven interrupts and the pin driven interrupts to wait until their code block is complete before "interrupting" each other. I was using the Metro library in my loop() function, but that seems unlikely to work, since that loop gets interrupted by the pin interrupts.
So for example, I've got code like
Code:
GPIOC_PDDR = GPIOC_PDDR & 0xff00;
I'm guessing there's something under the covers that pinMode() does that I'm unfamiliar with. While I tried to dig into pinMode()'s code to figure out what's going on, it's a rather complex block of code, and I'm not quite following what it's doing.
Is there a *canonical* description (or better yet, code example) of how to do direct port manipulation (both input and output) on Teensy 3.6 somewhere? I read the MK66FX1M0 chip documentation, but it's a bit overwhelming as well, or at least it's not obvious to me how I turn the descriptions there into working C code.
Also, if I've got a function I want to call say 40 times a second (25 mS intervals), and I've also got a bunch of input pin driven interrupts, what's the best way to set up the code so they don't interfere with each other? That is to say, I need both the clock driven interrupts and the pin driven interrupts to wait until their code block is complete before "interrupting" each other. I was using the Metro library in my loop() function, but that seems unlikely to work, since that loop gets interrupted by the pin interrupts.