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.

TM4C123GH6PM: Problems with PWM Signal

Part Number: TM4C123GH6PM


Hello,

i try to control a simple servo motor with PWM Signal. The configuration of the PWM Modul is below, but that did not work for me. Maybe someone has experience with the TM4C  and the PWM signal  and see the mistake. I followed the code on this Side which was also written for the TM4C123GH6PM: https://www.egr.msu.edu/classes/ece480/capstone/fall15/group09/appnotes/JoshuaLambApplicationNote.pdf

The names that i have entered, i found in the datasheet for the UC under PWM, at the Table for the PWM Signals. I can post a picture if that would help.

For this application, i want to use the Pin PF3. The Problem is, that the state of the Pin did not change, so it has always the same potenzial.

Maybe there is a problem with the configuration which i posted below ?

About help, i would be very happy.

void Init_PWM(void)
{
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);

    HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
    HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= 0x01;
    HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0;

    //site 1233 datasheet
    GPIOPinConfigure(GPIO_PF3_M1PWM7);

    GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_3);

    PWMGenConfigure(PWM1_BASE, PWM_GEN_3, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);

    PWMGenPeriodSet(PWM1_BASE, PWM_GEN_3, 8000000);

    //!!!!
    PWMPulseWidthSet(PWM1_BASE, PWM_OUT_7, 800000);

    PWMGenEnable(PWM1_BASE, PWM_GEN_3);

    PWMOutputState(PWM1_BASE, PWM_OUT_7_BIT , true);
}

  • Hi Torsten,

      I think the problem is the value you are loading to the period counter. In your  PWMGenPeriodSet() you are loading a value of 8000000. The PWM counter is only 16bit which allows a maximum of 65535.

    You can use the PWMClockSet() to divide the input clock to achieve the timebase you desire.

    If you are generating simple PWM you can also try the GPTM module. The GPTM module has

    32-bit timer and 64-bit timer that will greatly extend the range of the PWM period.

    Just curious about your application. Why would you need a PWM period that is almost

    0.5 second?

  • Thank you very much for your fast reply.

    I divided the clock and use a value in the range of 16 bit and now it works ^^.

    My mistake was, that i proofed the value which i should add, in der Driverlib datasheet, there it was 32 bit, shame on me. ^^

    For the future it is good to know that there is a module like the GPTM, thank you very much.

    At the beginning i use the value 1600000, which corresponds to 50hz with my oscillator. I wanted to measure this with a cheap multimeter, and the value was

    always 5 volt. So i thought it was to fast and this is the reason why the multimeter shows strange value, so i use longer signal times.: ) Unfortunately i don't have a oscilloskop and i didn't want to hang the servo directly on it, to prevent damage of the servo, but normally it should'nt be a problem to permanently put 5 volts on the servo i think.

    best regards,

    Torsten

  • Hi Torsten,

      Glad the problem is resolved. I think if you are into complex system design, a oscilloscope even a cheap version will greatly help you debug.