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.

PWM LM4F230H5QR

Other Parts Discussed in Thread: LM3S811

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);
}

  • Eran4576 said:
        GPIOPinConfigure(GPIO_PB6_M0PWM0);   
        GPIOPinConfigure(GPIO_PB7_M0PWM1);  
     
        GPIOPinConfigure(GPIO_PA6_M1PWM2);   
        GPIOPinConfigure(GPIO_PA7_M1PWM3);      

    Look closely - you've launched a 2nd PWM Module (M1) via pins PA6 & PA7.   Was this your intent?  Would be simpler if you confined all PWM outputs to the same PWM Module.  And you do have a "rich" assortment of candidate M0 pins: PB4,5; PE4,5; & PC4,5.  (Avoid PD0 as its use requires a, "trick.")  Suspect that your code shown never "enables" this 2nd PWM Module (M1) - thus your lack of output.

    SYSCTL_PERIPH_PWM0 & SYSCTL_PERIPH_PWM1 are both needed to bring up both PWM Modules!  (especially your "missing" M1)  Note - you used a "retired" PWM Module definition - which does not support your 2nd PWM module.  (did not know it existed)  Should you get an error w/use of tighter defined SYSCTL_PERIPH_PWMx you will have to update your older version of StellarisWare.  I still believe that your use of this 2nd PWM Module is resource wasteful.

    Note that you never actually set PWM Duty Cycle in the brief code extract. 

    PWMPulseWidthSet() is "normal/customary" means to set PWM Duty for each/every, individual PWM output.

    Believe this guidance gets you, "On the Air" with both PWM Generators... 

    Nice  Verified Answer "tick" appreciated - keeps "naked" 40W incand. on bit longer - lighting this back-room...

  • cb1,

    Another carefully and thoughtfully constructed assist - your dedication is commendable!

    I am a bit surprised you're not using LED lamps in that back-room however;-)

    Dave

  • Bonjour mon ami, Dave - always neat to see your considered posts as well.  This reporter does try - your kind comments far outweigh leaky mugs, ill-made T shirts offered as, equally, "considered reward..."

    Truth be told - back-room is behind yet another, "back-room" - fear that LED Lamp may impact otherwise pristine "atmosphere!"  (often - you really don't want to see...)

    When "Home Depot" offers 40W Led Lamps @ 100 for 29 USD (as paid for "doomsday" stock of incand) will retrace worn path - their door.  (and nego price-down...)

    Happy Labor Day and again thanks - kind comments...  Duly celebrating by "finishing off" July 4th, left-overs.