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.

enable pd1 with M0PWM6 and enable pd0 with M1PWM0



i was able to enable  pd0 with M1PWM0 but don't know how to enable pd1 with M0PWM6

here what i have so far 

code from workshop workbook lab 15 

http://www.mcu-turkey.com/wp-content/uploads/2013/12/TM4C123G_LaunchPad_Workshop_Workbook.pdf 

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/debug.h"
#include "driverlib/pwm.h"
#include "driverlib/pin_map.h"
#include "inc/hw_gpio.h"
#include "driverlib/rom.h"


#define PWM_FREQUENCY 55

int main(void)
{
volatile uint32_t ui32Load;
volatile uint32_t ui32PWMClock;
volatile uint8_t ui8Adjust;
ui8Adjust = 83;

ROM_SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
ROM_SysCtlPWMClockSet(SYSCTL_PWMDIV_64);

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

ROM_GPIOPinTypePWM(GPIO_PORTD_BASE, GPIO_PIN_0);
ROM_GPIOPinConfigure(GPIO_PD0_M1PWM0);

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;
ROM_GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_4|GPIO_PIN_0, GPIO_DIR_MODE_IN);
ROM_GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4|GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

ui32PWMClock = SysCtlClockGet() / 64;
ui32Load = (ui32PWMClock / PWM_FREQUENCY) - 1;
PWMGenConfigure(PWM1_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN);
PWMGenPeriodSet(PWM1_BASE, PWM_GEN_0, ui32Load);

ROM_PWMPulseWidthSet(PWM1_BASE, PWM_OUT_0, ui8Adjust * ui32Load / 1000);
ROM_PWMOutputState(PWM1_BASE, PWM_OUT_0_BIT, true);
ROM_PWMGenEnable(PWM1_BASE, PWM_GEN_0);

while(1)
{

if(ROM_GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4)==0x00)
{
ui8Adjust--;
if (ui8Adjust < 56)
{
ui8Adjust = 56;
}
ROM_PWMPulseWidthSet(PWM1_BASE, PWM_OUT_0, ui8Adjust * ui32Load / 1000);
}

if(ROM_GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_0)==0x00)
{
ui8Adjust++;
if (ui8Adjust > 111)
{
ui8Adjust = 111;
}
ROM_PWMPulseWidthSet(PWM1_BASE, PWM_OUT_0, ui8Adjust * ui32Load / 1000);
}

ROM_SysCtlDelay(100000);
}

}

  • Hello Rodolfo,

    Did you refer the datasheet for the microcontroller you are using? Please provide details of what you are trying to do and what debug steps you have taken to help us identify the issue and help you better.

    Also please use the code formatter option while posting the code to make it more readable.

    Thanks,
    Sai
  • Hi Rodolfo,

    Just wanted to alert you that in the TM4C123 launchpad pin PD0 is connected to pin PB6 and pin PD1 is connected to pin PB7 by 0ohm resistors.
    Look here where are the resistors:
    sites.google.com/.../note---common-errors

    The problem is that you did this:
    ROM_GPIOPinTypePWM(GPIO_PORTD_BASE, GPIO_PIN_0);

    You forgot to change to GPIO_PIN_1.
    I didn't check if there is anything more after seeing that so there might be some error after that.

    Btw you don't need to unlock this pin, only PD7 and PF0 require that.

    But do read Stellaris Sai comments, you should use the code format tool to spare our poor eyes, it will make the code much easier to read.

    Sai:
    So now moving to the Tiva forum too? :)
  • Luis Afonso said:
    So now moving to the Tiva forum too? :)

    Might you've missed the fact that "Sai's" (covering) now for the vacationing Amit?

  • I asked because I wanted to know if it was something like that or if Sai was gonna be here also :p

    And it worked, I have my answer from you