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.

CCS/DRV8803EVM: Having trouble getting an ouput from DRV8803EVM using PWM inputs genterated from TM4C1294XL Launchpad

Part Number: DRV8803EVM
Other Parts Discussed in Thread: DRV8803

Tool/software: Code Composer Studio

Hello, 

I am currently trying to drive a solenoid (1.2W max/ 24V power supply) using the DRV8803EVM with PWM inputs generated from the TM4C1294XL Launchpad. 

My problem right now is generating the PWM input from the pins on the TM4C1294XL Launchpad to the input pins on the DRV8803EVM board. 

I am producing a PWM wave when I go and look on the scope at my pins but it is not triggering any sort of output on the DRV8803EVM board. I want to be able to switch between two outputs (OUT1 and OUT2) on the EVM board to power two solenoids (1.2W max/ 24V power supply) but I don't think my PWM is correct when triggering an output from the DRV8803 when I attach my PWM pins on the TM4C1294XL Launchpad to the input pins on the EVM board. I am not sure if I don't have the correct frequency or amplitude or what?

For reference, I don't want to use the onboard MCU on the DRV8803 to complete my project because there is another input coming from the TM4C1294XL Launchpad that will be integrated into the code later (not by me). 

My code is below for reference. 

////*****************************************************************************
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "driverlib/gpio.h"
#include "driverlib/adc.h"
#include "driverlib/pin_map.h"
#include "driverlib/pwm.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
//////*****************************************************************************
//////
////// This function sets up UART0 to be used for a console to display information
////// as the example is running.
//////
void
GetADC(void)
{
#if defined(TARGET_IS_TM4C129_RA0) ||                                         \
    defined(TARGET_IS_TM4C129_RA1) ||                                         \
    defined(TARGET_IS_TM4C129_RA2)
    uint32_t ui32SysClock;
#endif

    uint32_t pui32ADC0Value[1];
#if defined(TARGET_IS_TM4C129_RA0) ||                                         \
    defined(TARGET_IS_TM4C129_RA1) ||                                         \
    defined(TARGET_IS_TM4C129_RA2)
    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                       SYSCTL_OSC_MAIN |
                                       SYSCTL_USE_PLL |
                                       SYSCTL_CFG_VCO_480), 20000000);
#else
    SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_16MHZ);
#endif

UARTprintf("ADC ->\n");
   UARTprintf("  Input Pin: AIN0/PE3\n\n");

   //
   // The ADC0 peripheral must be enabled for use.
   //
   SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

   //
   SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);


   GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);


   //
   ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);

   //
   // Configure step 0 on sequence 3.  Sample channel 0 (ADC_CTL_CH0) in
   // single-ended mode (default) and configure the interrupt flag
   // (ADC_CTL_IE) to be set when the sample is done.  Tell the ADC logic
   // that this is the last conversion on sequence 3 (ADC_CTL_END).  Sequence
   // 3 has only one programmable step.  Sequence 1 and 2 have 4 steps, and
   // sequence 0 has 8 programmable steps.  Since we are only doing a single
   // conversion using sequence 3 we will only configure step 0.  For more
   // information on the ADC sequences and steps, reference the datasheet.
   //
   ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE |
                            ADC_CTL_END);

   //
   // Since sample sequence 3 is now configured, it must be enabled.
   //
   ADCSequenceEnable(ADC0_BASE, 3);

   //
   // Clear the interrupt status flag.  This is done to make sure the
   // interrupt flag is cleared before we sample.
   //
   ADCIntClear(ADC0_BASE, 3);

   //
   // Sample AIN0 forever.  Display the value on the console.
   //
   int y;
   y=0;
   while(y<5)
   {
       //
       // Trigger the ADC conversion.
       //
       ADCProcessorTrigger(ADC0_BASE, 3);

       //
       // Wait for conversion to be completed.
       //
       while(!ADCIntStatus(ADC0_BASE, 3, false))
       {
       }

       //
       // Clear the ADC interrupt flag.
       //
       ADCIntClear(ADC0_BASE, 3);

       //
       // Read ADC Value.
       //
       ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value);

       //
       // Display the AIN0 (PE3) digital value on the console.
       //
       UARTprintf("AIN0 = %4d\r", pui32ADC0Value[0]);
       UARTprintf("\n");
       //
       // This function provides a means of generating a constant length
       // delay.  The function delay (in cycles) = 3 * parameter.  Delay
       // 250ms arbitrarily.
       //
#if defined(TARGET_IS_TM4C129_RA0) ||                                         \
   defined(TARGET_IS_TM4C129_RA1) ||                                         \
   defined(TARGET_IS_TM4C129_RA2)
       SysCtlDelay(ui32SysClock / 12);
#else
       SysCtlDelay(SysCtlClockGet() / 12);
#endif
       y++;
   }
}
//////*****************************************************************************
void
InitConsole(void)
{
////////    //
//////Enable GPIO port A which is used for UART0 pins.
////////    // TODO: change this to whichever GPIO port you are using.
////////    //
   SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
////////
////////    //
////////    // Configure the pin muxing for UART0 functions on port A0 and A1.
////////    // This step is not necessary if your part does not support pin muxing.
////////    // TODO: change this to select the port/pin you are using.
////////    //
   GPIOPinConfigure(GPIO_PA0_U0RX);
   GPIOPinConfigure(GPIO_PA1_U0TX);
////////
////////    //
////////    // Enable UART0 so that we can configure the clock.
////////    //
  SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
////////
////////    //
////////    // Use the internal 16MHz oscillator as the UART clock source.
////////    //
  UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
////////
////////    //
////////    // Select the alternate (UART) function for these pins.
////////    // TODO: change this to select the port/pin you are using.
////////    //
   GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
////////
////////    //
////////    // Initialize the UART for console I/O.
////////    //
   UARTStdioConfig(0, 115200, 16000000);
}
////
//////*****************************************************************************

//////
//////*****************************************************************************
#if defined(TARGET_IS_TM4C129_RA0) ||                                         \
        defined(TARGET_IS_TM4C129_RA1) ||                                         \
    defined(TARGET_IS_TM4C129_RA2)
    uint32_t g_ui32SysClock;
#endif
//////////
////////    //
//////    // Set the clocking to run directly from the external crystal/oscillator.
//////    // TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
//////    // crystal on your board.
//////    //
  #if defined(TARGET_IS_TM4C129_RA0) ||                                         \
      defined(TARGET_IS_TM4C129_RA1) ||                                         \
       defined(TARGET_IS_TM4C129_RA2)
       // g_ui32SysClock = SysCtlClockSet((SYSCTL_XTAL_25MHZ| SYSCTL_OSC_MAIN | SYSCTL_USE_OSC), 1200000);
#else
  SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_16MHZ);
#endif



////
////
    uint32_t sysclock;
////
    void main()
    {
        float PWM_FREQ;
        float CPU_FREQ;
        float pwm_word;
        int t;
        int i;
        InitConsole();
     //   GetADC();
////
        PWM_FREQ = 64000; //31.250kHz
        CPU_FREQ = 1000000;
        pwm_word = (1/PWM_FREQ)*CPU_FREQ;
    sysclock = SysCtlClockFreqSet((SYSCTL_XTAL_16MHZ |
                                                         SYSCTL_OSC_MAIN |
                                                         SYSCTL_USE_PLL |
                                                         SYSCTL_CFG_VCO_480), CPU_FREQ);
  //  GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED);
        i=0;
while(i<20)
{
        SysCtlPWMClockSet(SYSCTL_PWMDIV_1);//Set the clock speed
        SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); //Enable the correct port
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);//Enable the GPIO port
        GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_1);//Define the pine
        GPIOPinConfigure(GPIO_PG1_M0PWM5); //Comfigure the pin based on the datasheet
        PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);//Set the modes
       // UARTprintf("Gen config successful\n");
        PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, 300);
        PWMPulseWidthSet(PWM0_BASE, PWM_OUT_5,PWMGenPeriodGet(PWM0_BASE, PWM_GEN_2)/128);
        PWMOutputState(PWM0_BASE, PWM_OUT_5_BIT, true);
        PWMGenEnable(PWM0_BASE, PWM_GEN_2);
        UARTprintf("Running1\n");
      //  GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, RED_LED);
     //   SysCtlDelay(20000000);
        i++;
        GetADC();
}
    t=0;
while(t<20)
{
      SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
      SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
      SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
       GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_2);
              GPIOPinConfigure(GPIO_PG0_M0PWM4);
              PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_DB_NO_SYNC);
              UARTprintf("Gen config successful\n");
              PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, pwm_word);
              PWMPulseWidthSet(PWM0_BASE, PWM_OUT_4, PWMGenPeriodGet(PWM0_BASE, PWM_GEN_2)/128);

              PWMOutputState(PWM0_BASE, PWM_OUT_4_BIT, true);
             PWMGenEnable(PWM0_BASE, PWM_GEN_2);
             UARTprintf("Running2\n");
         //    SysCtlDelay(20000000);
              t++;
              GetADC();
}
////
////
////      //  UARTprintf("working\n");
   }