在PSOC Creator开发平台上,找到 Find code example里的TCPWMExample,希望对你有帮助,如下样例调用:
/* Enable the Interrupt component connected to interrupt */
TC_CC_ISR_StartEx(InterruptHandler);
/* Start the components */
TCPWM_Start();
/* Set Compare Mode */
TCPWM_SetMode(TCPWM_MODE_TIMER_COMPARE);
/* TCPWM Period & Compare */
TCPWM_WritePeriod(65535u);
TCPWM_WriteCompare(20000u);
/* Set UP Mode */
TCPWM_SetCounterMode(TCPWM_COUNT_UP);
/* Set Prescaler 1x */
TCPWM_SetPrescaler(TCPWM_PRESCALE_DIVBY1);
/* Set interrupt mode (TC/CC)*/
TCPWM_SetInterruptMode(TCPWM_INTR_MASK_CC_MATCH | TCPWM_INTR_MASK_TC);
/* Set start trigger */
TCPWM_TriggerCommand(TCPWM_MASK, TCPWM_CMD_START);