Teensy LC and infrared receive

Status
Not open for further replies.

profor

Active member
Hello,

i hope it is not mentioned here so i did not start useless thread, but this is not clear to me - in comparism of Teensy LC and Teensy 3.1
is mentioned no CMT timer on LC.

TeensyLCIR.JPG

Does this mean that i can not receive and decode IR or it means that Teensy can not send IR commands?


Thank You very much.
Dušan
 
If you use the IRremote library provided by Teensyduino, it works on Teensy-LC.

One of the FTM timers is automatically used, instead of CMT. Here's the code from inside IRremoteInt.h in that library.

Code:
// defines for TPM1 timer on Teensy-LC
#elif defined(IR_USE_TIMER_TPM1)
#define TIMER_RESET          FTM1_SC |= FTM_SC_TOF;
#define TIMER_ENABLE_PWM     CORE_PIN16_CONFIG = PORT_PCR_MUX(3)|PORT_PCR_DSE|PORT_PCR_SRE
#define TIMER_DISABLE_PWM    CORE_PIN16_CONFIG = PORT_PCR_MUX(1)|PORT_PCR_SRE
#define TIMER_ENABLE_INTR    NVIC_ENABLE_IRQ(IRQ_FTM1)
#define TIMER_DISABLE_INTR   NVIC_DISABLE_IRQ(IRQ_FTM1)
#define TIMER_INTR_NAME      ftm1_isr
#ifdef ISR
#undef ISR
#endif
#define ISR(f) void f(void)
#define TIMER_CONFIG_KHZ(val) ({                     \
        SIM_SCGC6 |= SIM_SCGC6_TPM1;                 \
        FTM1_SC = 0;                                 \
        FTM1_CNT = 0;                                \
        FTM1_MOD = (F_PLL/2000) / val - 1;           \
        FTM1_C0V = (F_PLL/6000) / val - 1;           \
        FTM1_SC = FTM_SC_CLKS(1) | FTM_SC_PS(0);     \
})
#define TIMER_CONFIG_NORMAL() ({                     \
        SIM_SCGC6 |= SIM_SCGC6_TPM1;                 \
        FTM1_SC = 0;                                 \
        FTM1_CNT = 0;                                \
        FTM1_MOD = (F_PLL/40000) - 1;                \
        FTM1_C0V = 0;                                \
        FTM1_SC = FTM_SC_CLKS(1) | FTM_SC_PS(0) | FTM_SC_TOF | FTM_SC_TOIE; \
})
#define TIMER_PWM_PIN        16

Other copies of IRremote you might find floating around the internet may not have this code, so use the one from Teensyduino. And as you can see on the last line, if transmitting, use pin 16 for your LED.
 
Status
Not open for further replies.
Back
Top