无论怎么配置TPM,都输出不了波形,而且计数器也不运行,不知怎么配置,下面是我的代码:
- void TPM_init()
- {
- SIM_SCGC6 |= (SIM_SCGC6_TPM0_MASK | SIM_SCGC6_TPM2_MASK);
- //PORTB_PCR18 |= PORT_PCR_MUX(3);
- //PORTB_PCR19 |= PORT_PCR_MUX(3);
- PORTD_PCR1 |= PORT_PCR_ISF_MASK | PORT_PCR_MUX(4) | PORT_PCR_DSE_MASK;
-
- NVIC_EnableIRQ(TPM0_IRQn);
-
- /*TPM0_SC |= TPM_SC_PS(1);
- TPM0_SC |= TPM_SC_CMOD(1);
- TPM0_SC |= TPM_SC_TOF_MASK;*/
-
- TPM0_CNT = 0;
- TPM0_MOD = 400;
- TPM0_SC |= TPM_SC_PS(1);
- TPM0_SC |= TPM_SC_TOIE_MASK | TPM_SC_CMOD(1);
- TPM0_C1SC |= TPM_CnSC_CHIE_MASK;
- TPM0_C1SC |= TPM_CnSC_MSA_MASK| TPM_CnSC_ELSA_MASK;
- TPM0_C1V = 100;
-
- TPM0_SC |= TPM_SC_TOF_MASK;
- //TPM0_C1SC |= 1;
- }
复制代码
此帖出自
小平头技术问答
我只知道有CW,想不到还有KDS,不过那两个还没用过
一周热门 更多>