educa
Active member
Hi,
I'm very new to teensy, but not that new to microcontrollers.
I'd like to create a gcode interpreter on the teensy and therefore I need to port some timing code too.
Now I could start banging this forum with all kinds of questions, but it looks fair to me that I study the K66 manual (developing for teensy 3.6) first.
Having 4 Flextimer counters, I believe I could use at least 3 of these for my timing specific code. (If I'm not wrong, then for example FTM0 has 8 channels, but they do all share the same 16 bit counter?
In my code I have to be able to enable 3 pins on the teensy (doesn't matter where they are on the pinout) by using the following principle. (as I think I read on the datasheet)
- I have to use 1 FTM per pin, because I want to start and stop them individually (really start/stop the whole 16bit counter, not just a channel)
- I set 1 pin high by assigning the correct ALT pinmux for for example FTM0_CH0
- I set an initial counter value in the 16bit counter for ftm0 and then also a compare value.
- Starting the counter, the external teensy pin is brought high and upon compare, the counter must automatically stop (1 shot mode?) and disable the pin.
- next time I want to enable the pin, I just (re)start the ftm0 counter?
I'm still reading up on this (a lot of data in the datasheet) and trying to get stuff working. As far as I understand (and recall from the m3 cpu on an arduino due) I don't really use interrupts for this. With this I mean that I don't install an ISR, but the counter should be directly configured in its registers so that on start, its external pin is set high and on compare, the counter is stopped and the pin is set low. It would be nice if on compare you can also directly let the counter be zeroed, but still need to find if that is possible.
Using this technique, it should be quite easy to have 3 external pins which I can !!start!! and they they should go high for respectively 10µS, 10µS and 3ms and auto-go-low without interrupting my software. It is perfectly possible on the arduino due so I can't imagine why I would not work on the teensy3.6
Now I do have a question for the savy people on here . There is a possibility that I would like to use millis(), micros(), elapsedMillis() and elapsedMicros()
Do these functions use some kind of timers internally (which I then better NOT touch in my lover level stuff) ?
Can I somewhere search the source code for the library functions made available ? I have found somewhere the code for timerone and timerthree libs and that gives a nice insight. Maybe it could be very valuable if I could somewhere find the source of the other libs/function calls. My common sense tells me they are available somewhere, but I just don't know where.
Kind regards,
Bart
I'm very new to teensy, but not that new to microcontrollers.
I'd like to create a gcode interpreter on the teensy and therefore I need to port some timing code too.
Now I could start banging this forum with all kinds of questions, but it looks fair to me that I study the K66 manual (developing for teensy 3.6) first.
Having 4 Flextimer counters, I believe I could use at least 3 of these for my timing specific code. (If I'm not wrong, then for example FTM0 has 8 channels, but they do all share the same 16 bit counter?
In my code I have to be able to enable 3 pins on the teensy (doesn't matter where they are on the pinout) by using the following principle. (as I think I read on the datasheet)
- I have to use 1 FTM per pin, because I want to start and stop them individually (really start/stop the whole 16bit counter, not just a channel)
- I set 1 pin high by assigning the correct ALT pinmux for for example FTM0_CH0
- I set an initial counter value in the 16bit counter for ftm0 and then also a compare value.
- Starting the counter, the external teensy pin is brought high and upon compare, the counter must automatically stop (1 shot mode?) and disable the pin.
- next time I want to enable the pin, I just (re)start the ftm0 counter?
I'm still reading up on this (a lot of data in the datasheet) and trying to get stuff working. As far as I understand (and recall from the m3 cpu on an arduino due) I don't really use interrupts for this. With this I mean that I don't install an ISR, but the counter should be directly configured in its registers so that on start, its external pin is set high and on compare, the counter is stopped and the pin is set low. It would be nice if on compare you can also directly let the counter be zeroed, but still need to find if that is possible.
Using this technique, it should be quite easy to have 3 external pins which I can !!start!! and they they should go high for respectively 10µS, 10µS and 3ms and auto-go-low without interrupting my software. It is perfectly possible on the arduino due so I can't imagine why I would not work on the teensy3.6
Now I do have a question for the savy people on here . There is a possibility that I would like to use millis(), micros(), elapsedMillis() and elapsedMicros()
Do these functions use some kind of timers internally (which I then better NOT touch in my lover level stuff) ?
Can I somewhere search the source code for the library functions made available ? I have found somewhere the code for timerone and timerthree libs and that gives a nice insight. Maybe it could be very valuable if I could somewhere find the source of the other libs/function calls. My common sense tells me they are available somewhere, but I just don't know where.
Kind regards,
Bart