Hi, Dave,
You are right, the resistor R96 and R98 are not populated, DNP means "Do Not Populated", so you can not see the FTM signal on B39 and B40 pins. But the PTD4 and PTD5 are also routed to pin A78 and A79, you can observe the FTM0_CH4 and FTM0_CH5 PWM signals on A78 and A79 pins on primary elevator board.
I have run the code pasted on TWR-K65F180M board, I can see the PWM signals on the two pins.
I attach the main.c, running the code, I can see the two PWM signals on the two pins.
Hope it can help you.
BR
Xiangjun Rong
#include "fsl_debug_console.h"
#include "board.h"
#include "fsl_ftm.h"
#include "fsl_device_registers.h"
#include "pin_mux.h"
#include <stdbool.h>
#include "clock_config.h"
#include "fsl_port.h"
/*******************************************************************************
* Definitions
******************************************************************************/
#define BOARD_FTM_BASEADDR FTM0
#define BOARD_FIRST_FTM_CHANNEL 0U
#define BOARD_SECOND_FTM_CHANNEL 1U
#define BOARD_FTM_CHANNEL4 4U
#define BOARD_FTM_CHANNEL5 5U
/* Get source clock for FTM driver */
#define FTM_SOURCE_CLOCK CLOCK_GetFreq(kCLOCK_BusClk)
/*******************************************************************************
* Prototypes
******************************************************************************/
/*!
* @brief delay a while.
*/
void delay(void);
void pinAssignment(void);
/*******************************************************************************
* Variables
******************************************************************************/
/*******************************************************************************
* Code
******************************************************************************/
void delay(void)
{
volatile uint32_t i = 0U;
for (i = 0U; i < 800000U; ++i)
{
__asm("NOP"); /* delay */
}
}
/*!
* @brief Main function
*/
int main(void)
{
bool brightnessUp = true; /* Indicate LEDs are brighter or dimmer */
ftm_config_t ftmInfo;
uint8_t updatedDutycycle = 0U;
ftm_chnl_pwm_signal_param_t ftmParam[2];
/* Configure ftm params with frequency 24kHZ */
ftmParam[0].chnlNumber = (ftm_chnl_t)BOARD_FTM_CHANNEL4; //BOARD_FIRST_FTM_CHANNEL;
ftmParam[0].level = kFTM_LowTrue;
ftmParam[0].dutyCyclePercent = 0U;
ftmParam[0].firstEdgeDelayPercent = 0U;
ftmParam[1].chnlNumber = (ftm_chnl_t)BOARD_FTM_CHANNEL5; //BOARD_SECOND_FTM_CHANNEL;
ftmParam[1].level = kFTM_LowTrue;
ftmParam[1].dutyCyclePercent = 0U;
ftmParam[1].firstEdgeDelayPercent = 0U;
/* Board pin, clock, debug console init */
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
pinAssignment();
/* Print a note to terminal */
PRINTF("\r\nFTM example to output PWM on 2 channels\r\n");
PRINTF("\r\nYou will see a change in LED brightness if an LED is connected to the FTM pin");
PRINTF("\r\nIf no LED is connected to the FTM pin, then probe the signal using an oscilloscope");
/*
* ftmInfo.prescale = kFTM_Prescale_Divide_1;
* ftmInfo.bdmMode = kFTM_BdmMode_0;
* ftmInfo.pwmSyncMode = kFTM_SoftwareTrigger;
* ftmInfo.reloadPoints = 0;
* ftmInfo.faultMode = kFTM_Fault_Disable;
* ftmInfo.faultFilterValue = 0;
* ftmInfo.deadTimePrescale = kFTM_Deadtime_Prescale_1;
* ftmInfo.deadTimeValue = 0;
* ftmInfo.extTriggers = 0;
* ftmInfo.chnlInitState = 0;
* ftmInfo.chnlPolarity = 0;
* ftmInfo.useGlobalTimeBase = false;
*/
FTM_GetDefaultConfig(&ftmInfo);
/* Initialize FTM module */
FTM_Init(BOARD_FTM_BASEADDR, &ftmInfo);
FTM_SetupPwm(BOARD_FTM_BASEADDR, ftmParam, 2U, kFTM_EdgeAlignedPwm, 24000U, FTM_SOURCE_CLOCK);
FTM_StartTimer(BOARD_FTM_BASEADDR, kFTM_SystemClock);
while (1)
{
/* Delay to see the change of LEDs brightness */
delay();
if (brightnessUp)
{
/* Increase duty cycle until it reach limited value */
if (++updatedDutycycle == 100U)
{
brightnessUp = false;
}
}
else
{
/* Decrease duty cycle until it reach limited value */
if (--updatedDutycycle == 0U)
{
brightnessUp = true;
}
}
/* Start PWM mode with updated duty cycle */
FTM_UpdatePwmDutycycle(BOARD_FTM_BASEADDR, (ftm_chnl_t)BOARD_FTM_CHANNEL4, kFTM_EdgeAlignedPwm,
updatedDutycycle);
FTM_UpdatePwmDutycycle(BOARD_FTM_BASEADDR, (ftm_chnl_t)BOARD_FTM_CHANNEL5, kFTM_EdgeAlignedPwm,
updatedDutycycle);
/* Software trigger to update registers */
FTM_SetSoftwareTrigger(BOARD_FTM_BASEADDR, true);
}
}
void pinAssignment(void)
{
CLOCK_EnableClock(kCLOCK_PortD);
/* Affects PORTD_PCR4 register */
PORT_SetPinMux(PORTD, 4U, kPORT_MuxAlt4);
/* Affects PORTD_PCR5 register */
PORT_SetPinMux(PORTD, 5U, kPORT_MuxAlt4);
}