1
NXPTM M522XX, KINETIS and i.MX RT / Re: Generate output clock with KL03Z
« on: August 28, 2016, 06:55:19 PM »
Thank you, Mark! I really appreciate your help.
Nov 2020: uTasker i.MX RT V1.4.12 is productive - with complete secure loading concept.
Follow uTasker updates at www.twitter.com/uTasker !!
Online Forum registration has now been disabled. Please send an email to an address at the bottom of the home page with your preferred user name and email address if you would like an account.
Return to uTasker main site: www.utasker.com
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#if defined KINETIS_KL
#if defined TPM_CLOCKED_FROM_OSCERCLK // {55}
#define TIMER_CLOCK (OSCERCLK)
#elif defined TPM_CLOCKED_FROM_MCGIRCLK
#define TIMER_CLOCK (MCGIRCLK)
#else
#if defined FLL_FACTOR
#define TIMER_CLOCK (MCGFLLCLK)
#else
#define TIMER_CLOCK (MCGPLLCLK/2)
#endif
#endif
#define PWM_CLOCK TIMER_CLOCK
#elif defined KINETIS_KE
#define TIMER_CLOCK (BUS_CLOCK)
#define PWM_CLOCK (BUS_CLOCK)
#else
#define TIMER_CLOCK (BUS_CLOCK)
#define PWM_CLOCK (SYSTEM_CLOCK/2)
#endif
#define TPM_CLOCKED_FROM_MCGIRCLK // TPM clock is connected to MCGIRCLK (either 32kHz or 4MHz)
#define USE_FAST_INTERNAL_CLOCK
#if defined USE_FAST_INTERNAL_CLOCK // if not selected the slow internal clock is used (when needed)
#define MCGIRCLK FAST_ICR // 4MHz, or 8MHz in mcg lite
#else
#define MCGIRCLK SLOW_ICR
PWM_INTERRUPT_SETUP pwm_setup;
pwm_setup.int_type = PWM_INTERRUPT;
pwm_setup.pwm_mode = (PWM_SYS_CLK | PWM_PRESCALER_1); // clock PWM timer from the IRC48M clock with /1 pre-scaler
pwm_setup.int_handler = 0; // no user interrupt call-back or DMA on PWM cycle
pwm_setup.pwm_frequency = PWM_TIMER_US_DELAY(TIMER_FREQUENCY_VALUE(500000), 8);
pwm_setup.pwm_value = _PWM_PERCENT(50, pwm_setup.pwm_frequency); // 50% PWM (high/low)
pwm_setup.pwm_reference = (_TIMER_0 | 0); // timer module 0, channel 0
fnConfigureInterrupt((void *)&pwm_setup); // enter configuration
#if defined KINETIS_KL03
_LPSCI0_Interrupt,
#else
#if defined USE_MAINTENANCE && (!(defined KWIKSTIK && defined SUPPORT_SLCD))
fnInitialisePorts(); // set up ports as required by the user
#endif
INTERRUPT_SETUP interrupt_setup; // interrupt configuration parameters
interrupt_setup.int_type = PORT_INTERRUPT; // identifier to configure port interrupt
interrupt_setup.int_handler = fn_nRF24L01_interrupt; // handling function
interrupt_setup.int_priority = nRF24L01P_IRQ_PRIORITY; // interrupt priority level
interrupt_setup.int_port = nRF24L01P_IRQ_PORT; // the port that the interrupt input is on
interrupt_setup.int_port_bits = nRF24L01P_IRQ; // the IRQ input connected
interrupt_setup.int_port_sense = (IRQ_FALLING_EDGE | PULLUP_ON); // interrupt is to be falling edge sensitive
fnConfigureInterrupt((void *)&interrupt_setup); // configure interrupt