Hello,
I have use Init_PWM() to use DC MOTOR1,2 via driver.
I was work on LM3S811 stellaris as is.
The DC MOTOR passes through Driver.
Today I currently working on LM4F230H5QR set the Init_PWM(), I change the porting and configuration.
But Only MOTOR#1 working and MOTOR#2 NOT..
Please, can anyone tell me why?
Thanks.
Eran
/* ---- Private Function Prototypes -------------------------------------- */
void Init_PWM()
{
SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
//
// Enable the peripherals used by this device. (PWM0,1,2,3)
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // PWM 0,1
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // PWM 2,3
GPIOPinConfigure(GPIO_PB6_M0PWM0);
GPIOPinConfigure(GPIO_PB7_M0PWM1);
GPIOPinConfigure(GPIO_PA6_M1PWM2);
GPIOPinConfigure(GPIO_PA7_M1PWM3);
//
// Set GPIO PWM pins. They are used to output the PWM0-3 signals
//
GPIOPinTypePWM(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7); //pwm0-1
GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6 | GPIO_PIN_7); //pwm2-3
//
// Set the period. For a 50 KHz frequency, the period = 1/50,000, or 20
// microseconds. For a 20 MHz clock, this translates to 400 clock ticks.
// Use this value to set the period.
//
ulPeriod = SysCtlClockGet() / PWMRATE;
//
// Set the PWM period to chosen rate.
//
PWMGenConfigure(PWM_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, ulPeriod);
PWMGenConfigure(PWM_BASE, PWM_GEN_1, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
PWMGenPeriodSet(PWM_BASE, PWM_GEN_1, ulPeriod);
PWMOutputInvert(PWM_BASE,PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT | PWM_OUT_3_BIT, true);
//
// Enable the PWM0 and PWM1 output signals.
//
PWMOutputState(PWM_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT | PWM_OUT_3_BIT, true);
//
// Enable the PWM generators.
//
PWMGenEnable(PWM_BASE, PWM_GEN_0);
PWMGenEnable(PWM_BASE, PWM_GEN_1);
}