Hi everyone!
I'm trying to port code from Teensy 3.x to Teensy 4.0
I need help with the following lines of code that are for Teensy 3.x. They need to be refined so that they work on Teensy 4.0
I need this to run the TLC5940 chips
If I can I can fine-tune the standard library I tried to optimize these lines by looking at the code of the TimerOne TimerThree library and the code from manitou48 (https://github.com/manitou48/teensy4). But my attempts to understand in vain, firstly I don't understand which line is responsible for what, and secondly because there is no manual on how to configure timers on Teensy 4.0
Please, help
I'm trying to port code from Teensy 3.x to Teensy 4.0
I need help with the following lines of code that are for Teensy 3.x. They need to be refined so that they work on Teensy 4.0
Code:
//BLANK_PIN -> pin 18 (A4) -> QuadTimer3 Module1
//XLAT_PIN -> pin 19 (A5) -> QuadTimer3 Module0
//GSCLK_PIN -> pin 5 -> FlexPWM2 Module1
//XLAT_PIN -> pin 19 (A5) -> QuadTimer3 Module0
#define set_XLAT_interrupt() FTM1_SC = FTM_SC_CLKS(1) | FTM_SC_CPWMS | FTM_SC_TOIE | (FTM1_SC & FTM_SC_PS(7))
#define clear_XLAT_interrupt() FTM1_SC = FTM_SC_CLKS(1) | FTM_SC_CPWMS | (FTM1_SC & FTM_SC_PS(7))
#define enable_XLAT_pulses() CORE_PIN3_CONFIG = PORT_PCR_MUX(3)|PORT_PCR_DSE|PORT_PCR_SRE
#define disable_XLAT_pulses() CORE_PIN3_CONFIG = PORT_PCR_MUX(1)|PORT_PCR_DSE|PORT_PCR_SRE
//GSCLK_PIN -> pin 5 -> FlexPWM2 Module1
SIM_SCGC4 |= SIM_SCGC4_CMT;
CMT_MSC = 0;
CMT_PPS = 0;
CMT_CGH1 = TLC_TIMER_TEENSY3_NORMAL_CGH1;
CMT_CGL1 = TLC_TIMER_TEENSY3_NORMAL_CGL1;
CMT_CMD1 = 1;
CMT_CMD2 = 0;
CMT_CMD3 = 0;
CMT_CMD4 = 0;
CMT_OC = 0x60;
CMT_MSC = 0x01;
CORE_PIN5_CONFIG = PORT_PCR_MUX(2)|PORT_PCR_DSE|PORT_PCR_SRE;
//BLANK_PIN -> pin 18 (A4) -> QuadTimer3 Module1
FTM1_SC = 0;
FTM1_MOD = TLC_TIMER_TEENSY3_NORMAL_MOD;
FTM1_CNT = 0;
FTM1_C0SC = 0x24;
FTM1_C1SC = 0x24;
FTM1_C0V = TLC_TIMER_TEENSY3_NORMAL_MOD - TLC_TIMER_TEENSY3_NORMAL_CV;
FTM1_C1V = TLC_TIMER_TEENSY3_NORMAL_MOD - TLC_TIMER_TEENSY3_NORMAL_CV - 1;
FTM1_SC = FTM_SC_CLKS(1) | FTM_SC_CPWMS;
NVIC_ENABLE_IRQ(IRQ_FTM1);
CORE_PIN4_CONFIG = PORT_PCR_MUX(3)|PORT_PCR_DSE|PORT_PCR_SRE;
I need this to run the TLC5940 chips
If I can I can fine-tune the standard library I tried to optimize these lines by looking at the code of the TimerOne TimerThree library and the code from manitou48 (https://github.com/manitou48/teensy4). But my attempts to understand in vain, firstly I don't understand which line is responsible for what, and secondly because there is no manual on how to configure timers on Teensy 4.0
Please, help