I was wondering why my code isnt working to turn the red led on using tpmo channel 0 with pwm. the code i have is:
SIM->SCGC5 |= SIM_SCGC5_PORTB_MASK;
SIM->SCGC6 |= SIM_SCGC6_TPM0_MASK;
PORTB->PCR[18] &=~PORT_PCR_MUX_MASK;
PORTB->PCR[18] |=PORT_PCR_MUX(3);
SIM->SOPT2 &= ~SIM_SOPT2_PLLFLLSEL_MASK;
SIM->SOPT2 |= SIM_SOPT2_TPMSRC(1);
TPM0->MOD = pwm_period-1;
TPM0->SC= TPM_SC_PS(0);
TPM0->CONF |= TPM_CONF_DBGMODE(3);
TPM0->CONTROLS[0].CnSC = TPM_CnSC_ELSA_MASK;
TPM0->CONTROLS[0].CnV = 0;
while(1)
{
TPM2->CONTROLS[0].CnV = 30;
}
Any help on what i need to change would help as i am new and still learning things
Hi
Please download the SDK_
The simple_pwm example in SDK_
The red led LEDRGB_RED is connect to PTB18 which is TPM2_CH0, please enable the clock gate of TPM2 instead of TPM0.
The Schematics of FRDM-KL25Z can be found here: Freedom Development Platform for Kinetis® KL14, KL15, KL24, KL25 MCUs
Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------