This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSPM0L1306-Q1: MSPM0L1306 PWM init code debug-初始化PWM的代码

Part Number: MSPM0L1306-Q1
Other Parts Discussed in Thread: SYSCONFIG

1. 用MSPM0L1306-Q1 (VSSOP 28封装)做了一个板子,现在可以开机和运行LED闪烁程序。

2. 正在debug PWM out的程序,用PA14(TIMG1, C0)输出,但是始终没有在示波器上看到PWM波,查过示波器设置没有问题。

3. 下面是PWM的初始化程序,麻烦查一下,看看是哪里的问题,谢谢!

#define GPIO_PWM_PORT                                                         (GPIOA)

#define GPIO_RGB_PWMOUTT_PIN                                          (DL_GPIO_PIN_14)

#define GPIO_IOMUX_RGB_PWMOUTT                                     (IOMUX_PINCM15)

#define GPIO_IOMUX_FUNC_PWMOUTT_PWM                        (IOMUX_PINCM15_PF_TIMG1_CCP0)


static const DL_TimerG_ClockConfig gLIGHTSENSOR_PWM_OUTT_INSTClockConfig = {
.clockSel = DL_TIMER_CLOCK_LFCLK,
.divideRatio = DL_TIMER_CLOCK_DIVIDE_1,
.prescale = 0,
};

static const DL_TimerG_PWMConfig gLIGHTSENSOR_PWM_OUTT_INSTConfig = {
.period = RGB_LED_PERIOD, /* 64Hz PWM signal for visible light */
.pwmMode = DL_TIMER_PWM_MODE_EDGE_ALIGN,
.startTimer = false,
};

void PWMout1_init(void)
{
DL_GPIO_initDigitalOutput(GPIO_IOMUX_RGB_PWMOUTT);

DL_GPIO_clearPins(GPIO_PWM_PORT, GPIO_RGB_PWMOUTT_PIN);

DL_GPIO_enableOutput(GPIO_PWM_PORT, GPIO_RGB_PWMOUTT_PIN);

DL_GPIO_initPeripheralOutputFunction(GPIO_IOMUX_RGB_PWMOUTT, GPIO_IOMUX_FUNC_PWMOUTT_PWM);

///========================================

DL_TimerG_setClockConfig(LIGHTSENSOR_PWM_OUT_INST,
(DL_TimerG_ClockConfig *) &gLIGHTSENSOR_PWM_OUTT_INSTClockConfig);

DL_TimerG_initPWMMode(LIGHTSENSOR_PWM_OUT_INST,
(DL_TimerG_PWMConfig *) &gLIGHTSENSOR_PWM_OUTT_INSTConfig);

/* Configure 50% duty cycle */
DL_TimerG_setCaptureCompareValue(
LIGHTSENSOR_PWM_OUT_INST, PWM_OUTT_PERIOD / 2, DL_TIMER_CC_1_INDEX);

DL_TimerG_clearInterruptStatus(
LIGHTSENSOR_PWM_OUT_INST, DL_TIMER_INTERRUPT_ZERO_EVENT);
DL_TimerG_enableInterrupt(
LIGHTSENSOR_PWM_OUT_INST, DL_TIMER_INTERRUPT_ZERO_EVENT);

DL_TimerG_enableClock(LIGHTSENSOR_PWM_OUT_INST);

DL_TimerG_setCCPDirection(LIGHTSENSOR_PWM_OUT_INST, DL_TIMER_CC1_OUTPUT);

DL_TimerG_startCounter(LIGHTSENSOR_PWM_OUT_INST);

}