IRLib compiles and works with Teensy 3.0/3.1 but not LC

Status
Not open for further replies.

Headroom

Well-known member
I am trying to get Infrared remote control working with a Teensy LC.
The code compiles and works perfectly with Teensy 3.0 and 3.1 ( don't have a 3.2 yet).

I've had good luck with using the IRlib library that another user here on the forum adapted to work with the Teensy 3.0 and 3.1

The code compiles and works fine for Teensy 3.0 and 3.1 and based on what I see in kinetis.h likely also with 3.2.

However when I select the Teensy LC as the board the compiler complains about "IRQ_CMT' was not declared in this scope:
Screen Shot 2015-11-26 at 10.19.54 PM.png

And sure enough the section for Teensy LC is missing such a definition while hit's present in the Teensy 3.0/3.1/3.2 sections.

Any help and suggestion is appreciated.
 
In IRLibTimer.h there are the lines:

Code:
/* Teensy 3.0 & 3.1 */
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
  #define IR_SEND_TIMER_CMT 5

Try changing this to:

Code:
/* Teensy 3.0, 3.1, 3.2, and LC */
#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__)
  #define IR_SEND_TIMER_CMT 5

Note, the receiver uses interrupts, and not all pins on the LC can support interrupts. So, you would need to check whether the pin you use can support interrupts.
 
Tried that already but thanks for the help!

What needs to be added is actually this as a separate definition not the same but equivalent to what can be found in IRremoteInt.h:
Code:
#elif defined(__MKL26Z64__)
  #define IR_SEND_TIMER_TPM1 16 // tx = pin 16
[code/]

But there is more Teensy LC specific stuff in IRremoteInt.h which I need to patch into IRLibTimer.h. Just have not exactly found where that needs to go:
[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
 
I am getting closer to have the Teensy LC work, at least for decoding IR signals.
The IRhashdecode.ino sample sketch already works. Now I have to figure out why the code that I wrote and which uses the same library only works with a Teensy 3 but not the Teensy LC.
 
Status
Not open for further replies.
Back
Top