I am trying to enable PWM using PC4/5. I understand from the documentation that I must set PMC field and possibly GPIOAFSEL to enable these pins. I cannot find a syntax example to make this possible. Can somebody please provide some assistance on how to write to these registers?
I have left out the portion of setting up the PWM clock. The code worked until I tried to move it to different pins.
Thanks in advance for any help.
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); //PWM
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); //PWM
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //GPIO
/*
* Left motor
*/
GPIOPinTypePWM(GPIO_PORTC_BASE, GPIO_PIN_4);
GPIOPinConfigure(GPIO_PC4_M0PWM6);
/*
* right motor
*/
GPIOPinTypePWM(GPIO_PORTC_BASE, GPIO_PIN_5); //pin1 = left motor, pin2 = right motor
GPIOPinConfigure(GPIO_PC5_M0PWM7);
PWMGenConfigure(PWM0_BASE, PWM_GEN_3, PWM_GEN_MODE_DOWN);
/*
* left motor
*/
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_6, 0); // no motor speed
PWMOutputState(PWM0_BASE, PWM_OUT_6_BIT, true);
/*
* right motor
*/
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_7, 0); // no motor speed
PWMOutputState(PWM0_BASE, PWM_OUT_7_BIT, true);
PWMGenEnable(PWM0_BASE, PWM_GEN_3);
PWMPulseWidthSet(PWM0_BASE, motor, 50 * ui32Load / 1000 );