Hi all,
there is a simple modification of ftm driver example based on KSDK 1.3, KDS 3.0 on FRDM-K22F.
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTD_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); PORT_HAL_SetMuxMode(PORTA,1u,kPortMuxAlt3);//red PORT_HAL_SetMuxMode(PORTA,2u,kPortMuxAlt3);//green PORT_HAL_SetMuxMode(PORTD,5u,kPortMuxAlt4);//blue /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); }
ftm_pwm_param_t ftmParamR = { .mode = kFtmEdgeAlignedPWM, .edgeMode = kFtmLowTrue, .uFrequencyHZ = 24000u, .uDutyCyclePercent = 0, .uFirstEdgeDelayPercent = 0, };
FTM_DRV_PwmStart(BOARD_FTM_INSTANCE, &ftmParamR, 6); FTM_DRV_PwmStart(BOARD_FTM_INSTANCE, &ftmParamG, 7); FTM_DRV_PwmStart(BOARD_FTM_INSTANCE, &ftmParamB, 5);
hsv2rgb(hue,255,255,&red,&green,&blue,255);
hue++; if(hue>=360)hue=0;
ftmParamR.uDutyCyclePercent = (uint8_t)(((float)red/255.0)*100.0); ftmParamG.uDutyCyclePercent = (uint8_t)(((float)green/255.0)*100.0); ftmParamB.uDutyCyclePercent = (uint8_t)(((float)blue/255.0)*100.0);
That´s all!
Importing example
and choose .wsd file
After then don´t forget compile library first and then project.
I hope you will enjoy the demo
Iva