Posted: 22 May 2012, 04:05
Hello everyone!
I have been trying to generate a pwm output using the code given below using the code base. However I do not get output when I connect the P1.9 to the oscilloscope. It builds without error but no output on debug.It would be great if anyone can help me find the problem. Thankyou.
static void timer16PWMInit()
{
/* Enable the clock for CT16B1 */
SCB_SYSAHBCLKCTRL |= (SCB_SYSAHBCLKCTRL_CT16B1);
/* Configure PIO1.9 as Timer1_16 MAT0 Output */
IOCON_PIO1_9 &= ~IOCON_PIO1_9_FUNC_MASK;
IOCON_PIO1_9 |= IOCON_PIO1_9_FUNC_CT16B1_MAT0;
/* Set period (MR3) to 2ms */
TMR_TMR16B1MR3 = TIMER16_CCLK_1MS * 2;
/* Set Duty Cycle (MR0) to 50% */
TMR_TMR16B1MR0 = TIMER16_CCLK_1MS * 1;
/* Configure match control register to reset on MR3 */
TMR_TMR16B1MCR = (TMR_TMR16B1MCR_MR3_RESET_ENABLED);
/* External Match Register Settings for PWM */
TMR_TMR16B1EMR = TMR_TMR16B1EMR_EMC0_TOGGLE | TMR_TMR16B1EMR_EM0;
/* Enable PWM0 and PWM3 */
TMR_TMR16B1PWMC = TMR_TMR16B1PWMC_PWM0_ENABLED | TMR_TMR16B1PWMC_PWM3_ENABLED;
/* Enable Timer1 */
TMR_TMR16B1TCR = TMR_TMR16B1TCR_COUNTERENABLE_ENABLED;
}