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.

TM4C123 PWM

Hey,

I have a problem about configure PWM. I can't see anything from PC4 output. 

Here is my init function:

void PWM_Init(void)
{
	unsigned long delay;
	SYSCTL_RCGC0_R |= 0x00100000; // SYSCTL_RCGC0_PWM0;  // 1) Enable the PWM clock
	SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOC; // 2) PortC Clock(PC4-M0PWM6; PWM out)
	delay = SYSCTL_RCGC2_R;
	GPIO_PORTC_AFSEL_R |= 0x10; // PC4 - Alt. Funct.
	GPIO_PORTC_PCTL_R &= ~0x000F0000;
	GPIO_PORTC_PCTL_R  |= 0x00040000; // M0PWM6
	GPIO_PORTC_AMSEL_R &= ~0x10; // Disable analog
	GPIO_PORTC_DEN_R |= 0x10; // PF2 Digital enabled
	
	SYSCTL_RCC_R |= SYSCTL_RCC_USEPWMDIV; // Use PWM divider
	SYSCTL_RCC_R &= ~SYSCTL_RCC_PWMDIV_M; // clear divider
	SYSCTL_RCC_R |= SYSCTL_RCC_PWMDIV_64; // /64 divider
	
	// Module 0 PWM Generator 3
	PWM0_3_CTL_R = 0; // disable for config
	PWM0_3_GENA_R = 0x0000008C;
	PWM0_3_LOAD_R = 0x0000013F; // 80Mhz/16=1,250,000hz / 50 = 25,000 (period, 50hz)
	PWM0_3_CMPA_R = 0x0000010F; // 50% duty. (12,500)
	PWM0_3_CTL_R =  0x00000001; // enable
	PWM0_ENABLE_R = 0x40; // PWM0_ENABLE_R |= PWM_ENABLE_PWM6EN;
}

Thanks for any help.

  • Hello Yasin,

    We do not support the DRM style of coding. There are examples for PWM in TivaWare which uses the TivaWare APIs and are proven to be working. I would suggest using the same.
  • Amit Ashara said:
    We do not support the DRM style of coding. There are examples for PWM in TivaWare

    Good for you, Amit.   Predictably - posters electing complex methods will fail - you've provided the, "Tried, true, tested" Best Path to poster success!

    Now when ALL vendor staff provide this, "Avoid use of DRM/ASM" direction - that consistency has the greatest chance of being well noted...