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.

Closes Tiva replacement for the LM3S2616

Other Parts Discussed in Thread: LM3S2616, TM4C123BE6PM, TM4C123GH6PM

Hello TI Team,

We are in a bind right now with the LM3S2616 hard to find parts and long lead times.  We decided to redesign our board base on the LM3S2616 with a Tiva part

but before we do that we want it to know if most of our code on the LM3S2616, which is base on the stellaris ware, could be reused on the Tiva part with the

Tivaware.

If the porting is minimum then we would like to know what part on the TIVAC series would be closes compatible with the LM3S2616.

Thanks. 

  • Hi Moises,

    I'm sorry to hear about your troubles with lead times. The good news is that it should be fairly easy to migrate your design to the Tiva series.

    See this guide for migrating designs from LM3S to TM4C123x. Also take a look at this guide for migrating software from StellarisWare to TivaWare.

    Additionally, we provide a tool that will match Stellaris parts to their closest Tiva equivalent. For the LM3S2616 we recommend the TM4C123BE6.

    Regards,

    Sam

  • Sam Friedman said:

    Additionally, we provide a tool that will match Stellaris parts to their closest Tiva equivalent. For the LM3S2616 we recommend the TM4C123BE6.

    This tool is a great idea. Unfortunately, all three Stellaris microcontrollers that I've been involved with give a tool result of  "This part is currently in development. For more information contact your local TI representative". Any chance of at least updating the tool to give the approximate introduction date (just which quarter and year will be fine enough resolution). [It's OK to contact the TI rep, but sometimes you just want a quick inquiry (and quick inquiry updates.]

  • Hi Vito,

    I like that suggestion!  Thank you.  I will ask the web team if they can add the product availability information to the tool.

    Regards,

    Sue

  • Hello Sam,

    Thank you for the Links to the guide files, in particular the spma050a.pdf guide.

    Now, we move all the LM3S2616 stellarisware code to the TM4C123BE6PM part using TIVAWARE

    but are having difficulties with the ADC and Sequencers.

    The code that use the ADC0 and Sequencer 0 works just find with StellarisWare and the LM3S2616.

    I can compile the code and debug the code using CCS5.4, just find.

    But when I transition to the Tivaware and the TM4C123BE6PM part the ADC0 code and Sequencer 0 no longer

    work.  In fact I get a hardware fault at:

    //Make sure ADC sequencer 0 is disable
    ROM_ADCSequenceDisable(ADC0_BASE, 0);
    ROM_SysCtlDelay(10);                             //Some delay
    ROM_ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PWM1, 0);

    Any ideas as to why I am not able to configure the ADC0 and Sequencer 0?

    We also gotten the TivaC LaunchPad and reconfigured the project to use the TM4C123GH6PM part

    with same results.

    Notes:

    1) startup_ccs.c has appropriate interrupt handlers.  

    0508.startup_ccs.c
    //*****************************************************************************
    //
    // startup_ccs.c - Startup code for use with TI's Code Composer Studio.
    //
    // Copyright (c) 2012-2013 Texas Instruments Incorporated.  All rights reserved.
    // Software License Agreement
    // 
    // Texas Instruments (TI) is supplying this software for use solely and
    // exclusively on TI's microcontroller products. The software is owned by
    // TI and/or its suppliers, and is protected under applicable copyright
    // laws. You may not combine this software with "viral" open-source
    // software in order to form a larger program.
    // 
    // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
    // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
    // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
    // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
    // DAMAGES, FOR ANY REASON WHATSOEVER.
    // 
    // This is part of revision 1.0 of the EK-TM4C123GXL Firmware Package.
    //
    //*****************************************************************************
    
    #include <stdint.h>
    #include "inc/hw_nvic.h"
    #include "inc/hw_types.h"
    
    //*****************************************************************************
    //
    // Forward declaration of the default fault handlers.
    //
    //*****************************************************************************
    void ResetISR(void);
    static void NmiSR(void);
    static void FaultISR(void);
    static void IntDefaultHandler(void);
    
    //*****************************************************************************
    //
    // External declaration for the reset handler that is to be called when the
    // processor is started
    //
    //*****************************************************************************
    extern void _c_int00(void);
    
    //*****************************************************************************
    //
    // Linker variable that marks the top of the stack.
    //
    //*****************************************************************************
    extern uint32_t __STACK_TOP;
    
    //*****************************************************************************
    //
    // External declarations for the interrupt handlers used by the application.
    //
    //*****************************************************************************
    extern void ADCIntHandler(void);
    extern void ControllerIntHandler(void);
    extern void UART0IntHandler(void);
    //extern void WatchdogIntHandler(void);
    
    //*****************************************************************************
    //
    // The vector table.  Note that the proper constructs must be placed on this to
    // ensure that it ends up at physical address 0x0000.0000 or at the start of
    // the program if located at a start address other than 0.
    //
    //*****************************************************************************
    #pragma DATA_SECTION(g_pfnVectors, ".intvecs")
    void (* const g_pfnVectors[])(void) =
    {
        (void (*)(void))((uint32_t)&__STACK_TOP),
                                                // The initial stack pointer
        ResetISR,                               // The reset handler
        NmiSR,                                  // The NMI handler
        FaultISR,                               // The hard fault handler
        IntDefaultHandler,                      // The MPU fault handler
        IntDefaultHandler,                      // The bus fault handler
        IntDefaultHandler,                      // The usage fault handler
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        IntDefaultHandler,                      // SVCall handler
        IntDefaultHandler,                      // Debug monitor handler
        0,                                      // Reserved
        IntDefaultHandler,                      // The PendSV handler
        IntDefaultHandler,                      // The SysTick handler
        IntDefaultHandler,                      // GPIO Port A
        IntDefaultHandler,                      // GPIO Port B
        IntDefaultHandler,                      // GPIO Port C
        IntDefaultHandler,                      // GPIO Port D
        IntDefaultHandler,                      // GPIO Port E
        UART0IntHandler,                      	// UART0 Rx and Tx
        IntDefaultHandler,                      // UART1 Rx and Tx
        IntDefaultHandler,                      // SSI0 Rx and Tx
        IntDefaultHandler,                      // I2C0 Master and Slave
        IntDefaultHandler,                      // PWM Fault
        IntDefaultHandler,                      // PWM Generator 0
        IntDefaultHandler,                      // PWM Generator 1
        IntDefaultHandler,                      // PWM Generator 2
        IntDefaultHandler,                      // Quadrature Encoder 0
        ADCIntHandler,                      	// ADC Sequence 0
        IntDefaultHandler,                      // ADC Sequence 1
        IntDefaultHandler,                      // ADC Sequence 2
        IntDefaultHandler,                      // ADC Sequence 3
        IntDefaultHandler,                     	// Watchdog timer
        IntDefaultHandler,                      // Timer 0 subtimer A
        IntDefaultHandler,                      // Timer 0 subtimer B
        IntDefaultHandler,                      // Timer 1 subtimer A
        IntDefaultHandler,                      // Timer 1 subtimer B
        IntDefaultHandler,                      // Timer 2 subtimer A
        IntDefaultHandler,                      // Timer 2 subtimer B
        IntDefaultHandler,                      // Analog Comparator 0
        IntDefaultHandler,                      // Analog Comparator 1
        IntDefaultHandler,                      // Analog Comparator 2
        IntDefaultHandler,                      // System Control (PLL, OSC, BO)
        IntDefaultHandler,                      // FLASH Control
        IntDefaultHandler,                      // GPIO Port F
        IntDefaultHandler,                      // GPIO Port G
        IntDefaultHandler,                      // GPIO Port H
        IntDefaultHandler,                      // UART2 Rx and Tx
        IntDefaultHandler,                      // SSI1 Rx and Tx
        IntDefaultHandler,                      // Timer 3 subtimer A
        IntDefaultHandler,                      // Timer 3 subtimer B
        IntDefaultHandler,                      // I2C1 Master and Slave
        IntDefaultHandler,                      // Quadrature Encoder 1
        IntDefaultHandler,                      // CAN0
        IntDefaultHandler,                      // CAN1
        IntDefaultHandler,                      // CAN2
        0,                                      // Reserved
        IntDefaultHandler,                      // Hibernate
        IntDefaultHandler,                      // USB0
        ControllerIntHandler,                   // PWM Generator 3
        IntDefaultHandler,                      // uDMA Software Transfer
        IntDefaultHandler,                      // uDMA Error
        IntDefaultHandler,                      // ADC1 Sequence 0
        IntDefaultHandler,                      // ADC1 Sequence 1
        IntDefaultHandler,                      // ADC1 Sequence 2
        IntDefaultHandler,                      // ADC1 Sequence 3
        0,                                      // Reserved
        0,                                      // Reserved
        IntDefaultHandler,                      // GPIO Port J
        IntDefaultHandler,                      // GPIO Port K
        IntDefaultHandler,                      // GPIO Port L
        IntDefaultHandler,                      // SSI2 Rx and Tx
        IntDefaultHandler,                      // SSI3 Rx and Tx
        IntDefaultHandler,                      // UART3 Rx and Tx
        IntDefaultHandler,                      // UART4 Rx and Tx
        IntDefaultHandler,                      // UART5 Rx and Tx
        IntDefaultHandler,                      // UART6 Rx and Tx
        IntDefaultHandler,                      // UART7 Rx and Tx
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        IntDefaultHandler,                      // I2C2 Master and Slave
        IntDefaultHandler,                      // I2C3 Master and Slave
        IntDefaultHandler,                      // Timer 4 subtimer A
        IntDefaultHandler,                      // Timer 4 subtimer B
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        IntDefaultHandler,                      // Timer 5 subtimer A
        IntDefaultHandler,                      // Timer 5 subtimer B
        IntDefaultHandler,                      // Wide Timer 0 subtimer A
        IntDefaultHandler,                      // Wide Timer 0 subtimer B
        IntDefaultHandler,                      // Wide Timer 1 subtimer A
        IntDefaultHandler,                      // Wide Timer 1 subtimer B
        IntDefaultHandler,                      // Wide Timer 2 subtimer A
        IntDefaultHandler,                      // Wide Timer 2 subtimer B
        IntDefaultHandler,                      // Wide Timer 3 subtimer A
        IntDefaultHandler,                      // Wide Timer 3 subtimer B
        IntDefaultHandler,                      // Wide Timer 4 subtimer A
        IntDefaultHandler,                      // Wide Timer 4 subtimer B
        IntDefaultHandler,                      // Wide Timer 5 subtimer A
        IntDefaultHandler,                      // Wide Timer 5 subtimer B
        IntDefaultHandler,                      // FPU
        0,                                      // Reserved
        0,                                      // Reserved
        IntDefaultHandler,                      // I2C4 Master and Slave
        IntDefaultHandler,                      // I2C5 Master and Slave
        IntDefaultHandler,                      // GPIO Port M
        IntDefaultHandler,                      // GPIO Port N
        IntDefaultHandler,                      // Quadrature Encoder 2
        0,                                      // Reserved
        0,                                      // Reserved
        IntDefaultHandler,                      // GPIO Port P (Summary or P0)
        IntDefaultHandler,                      // GPIO Port P1
        IntDefaultHandler,                      // GPIO Port P2
        IntDefaultHandler,                      // GPIO Port P3
        IntDefaultHandler,                      // GPIO Port P4
        IntDefaultHandler,                      // GPIO Port P5
        IntDefaultHandler,                      // GPIO Port P6
        IntDefaultHandler,                      // GPIO Port P7
        IntDefaultHandler,                      // GPIO Port Q (Summary or Q0)
        IntDefaultHandler,                      // GPIO Port Q1
        IntDefaultHandler,                      // GPIO Port Q2
        IntDefaultHandler,                      // GPIO Port Q3
        IntDefaultHandler,                      // GPIO Port Q4
        IntDefaultHandler,                      // GPIO Port Q5
        IntDefaultHandler,                      // GPIO Port Q6
        IntDefaultHandler,                      // GPIO Port Q7
        IntDefaultHandler,                      // GPIO Port R
        IntDefaultHandler,                      // GPIO Port S
        IntDefaultHandler,                      // PWM 1 Generator 0
        IntDefaultHandler,                      // PWM 1 Generator 1
        IntDefaultHandler,                      // PWM 1 Generator 2
        IntDefaultHandler,                      // PWM 1 Generator 3
        IntDefaultHandler                       // PWM 1 Fault
    };
    
    //*****************************************************************************
    //
    // This is the code that gets called when the processor first starts execution
    // following a reset event.  Only the absolutely necessary set is performed,
    // after which the application supplied entry() routine is called.  Any fancy
    // actions (such as making decisions based on the reset cause register, and
    // resetting the bits in that register) are left solely in the hands of the
    // application.
    //
    //*****************************************************************************
    void
    ResetISR(void)
    {
        //
        // Jump to the CCS C initialization routine.  This will enable the
        // floating-point unit as well, so that does not need to be done here.
        //
        __asm("    .global _c_int00\n"
              "    b.w     _c_int00");
    }
    
    //*****************************************************************************
    //
    // This is the code that gets called when the processor receives a NMI.  This
    // simply enters an infinite loop, preserving the system state for examination
    // by a debugger.
    //
    //*****************************************************************************
    static void
    NmiSR(void)
    {
        //
        // Enter an infinite loop.
        //
        while(1)
        {
        }
    }
    
    //*****************************************************************************
    //
    // This is the code that gets called when the processor receives a fault
    // interrupt.  This simply enters an infinite loop, preserving the system state
    // for examination by a debugger.
    //
    //*****************************************************************************
    static void
    FaultISR(void)
    {
        //
        // Enter an infinite loop.
        //
        while(1)
        {
        }
    }
    
    //*****************************************************************************
    //
    // This is the code that gets called when the processor receives an unexpected
    // interrupt.  This simply enters an infinite loop, preserving the system state
    // for examination by a debugger.
    //
    //*****************************************************************************
    static void
    IntDefaultHandler(void)
    {
        //
        // Go into an infinite loop.
        //
        while(1)
        {
        }
    }
    

    2) in main I have enable pheripherals. 

    4520.main.c
    /*
     * main.c
     *
     *  Created on: Apr 29, 2013
     *      Author: Moises
     *
     *
     *		Issue:	 2.0
     *      Version: 1.0
     *      Project: Savaria's motor controller
     *
     *		Date: 8/28/2013
     *      upgrade: Move Code from StellarisWare to TivaWare because new boards use New Tiva C controller
     *
     *
     */
    
    #include <stdint.h>
    #include <stdbool.h>		//These are require because of C99 Coding standard
    
    #include "inc/hw_gpio.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/rom_map.h"
    
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_nvic.h"
    #include "inc/hw_types.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/rom.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/watchdog.h"
    //#include "utils/uartstdio.h"
    
    #include "muartstdio.h"
    #include "button.h"
    #include "io.h"
    //#include "ads1015.h"		//deprecated new controller has no external ADC
    #include "constants.h"
    #include "uart.h"
    #include "hbridge.h"
    #include "controller.h"
    #include "adc.h"
    #include "limit.h"
    #include "wdog.h"
    #include "debug_msg.h"
    
    uint16_t mt;
    
    MOTOR_CONTROLLER mes896;
    
    uint32_t mtemp;
    uint32_t mdec;
    uint32_t mI;
    uint32_t ms;
    
    const char *DEBUG_DOOR_STATE [10] = {
    		"NEUTRAL",
    		"OPEN_NORMAL",
    		"OPEN_PUSHNGO",
    		"OPEN_TIME",
    		"DOOR CLOSING",
    		"DOOR HOLD",
    		"2 INCHES ON CLOSING",
    		"2 INCHES ON OPENING",
    		"DOOR OPENNING",
    		"OBSTRUCTION"
    };
    
    const char *DEBUG_DOOR_CYCLES [7] = {
    		"OPEN START",
    		"OPEN END",
    		"REOPEN",
    		"CLOSE START",
    		"CLOSE END",
    		"RECLOSE",
    		"IDLE"
    };
    
    const char *DEBUG_CONTROLLER_STATE [4] = {
    	"WAIT_FOR_LINK",
    	"RUNNING",
    	"FAULTED",
    	"IDLE"
    };
    
    const char *DEBUG_CONTROLLER_FAULTS [5] = {
    	"NONE",
    	"BUS VOLTAGE",
    	"BATTERY VOLTAGE",
    	"TEMPERATURE",
    	"CURRENT"
    };
    
    const char *DEBUG_MOTOR_STATE [3] = {
    		"STOPPED",
    		"FORWARD",
    		"REVERSE"
    };
    
    const char *DEBUG_OPERATION_MODE [2] = {
    		"NORMAL",
    		"PRO"
    };
    
    const char *DEBUG_OBSTRUCTION_SENSOR [2] = {
    		"ENABLE",
    		"DISABLE"
    };
    
    const char *DEBUG_OPEN_DOOR_DELAY [2] = {
    		"DELAY ON",
    		"DELAY OFF"
    };
    
    //*****************************************************************************
    //
    // The error routine that is called if the driver library encounters an error.
    //
    //*****************************************************************************
    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ulLine)
    {
    }
    #endif
    
    //*****************************************************************************
    //
    // This function is used to safely call the boot loader and will never return.
    //
    //*****************************************************************************
    void CallBootloader(void)
    {
        //
        // Disable all processor interrupts.  Instead of disabling them one
        // at a time (and possibly missing an interrupt if new sources are
        // added), a direct write to NVIC is done to disable all peripheral
        // interrupts.
        //
        HWREG(NVIC_DIS0) = 0xffffffff;
        HWREG(NVIC_DIS1) = 0xffffffff;
    
        //
        // Clear any active interrupts.  If the boot loader uses any
        // interrupts, they will therefore respond as expected.
        //
        HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_VECT_CLR_ACT;
    
        //
        // Set the HBridge to a safe state before the firmware update
        // starts.
        //
        HBridgeFirmwareUpdate();
    
        //
        // Set the LED to indicate that a firmware update is occurring.
        //
        LEDFirmwareUpdate();
    
        //
        // Call the boot loader.
        //
        (*((void (*)(void))(*(uint32_t *)0x2c)))();
    
        //
        // Loop forever.  This should never be reached.
        //
        while(1)
        {
        }
    }
    
    
    int main(void)
    {
        //
        // Set the clocking to run from the main oscillator.
        //
        ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                           SYSCTL_XTAL_16MHZ);
    
        //
        // Enable the peripherals used by this application.
        //
    //    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    //    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    //    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    //    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    //    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    //    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    //    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
    //    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    //    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);
    //    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);	//deprecated old LM3S2616
    
        //
        // Enable Peripheral Clocks
        //
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
        //MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    
    
        //
        // Initialize the UART.
        //
        ROM_GPIOPinTypeUART(UART_RX_PORT, UART_RX_PIN | UART_TX_PIN);
        UARTStdioInit(0);	// see muartstdio.c
    
        //
        // SAVARIA MES896 MOTOR CONTROLLER
        //
        UARTprintf("\n");
        UARTprintf("********** SAVARIA DOOR CONTROLLER **********\n");
    
        //
        // Set the priorities of the interrupts.  The following interrupts are used
        // (listed in priority from highest to lowest):
        //
        //     Watchdog    -
        //
        //
        //     ADC0        - The completion of an ADC sampling.
        //
        //
        //     UART0       - The UART <-> For DEBUG
        //
        //ROM_IntPrioritySet(INT_WATCHDOG, 0x00);
        ROM_IntPrioritySet(INT_ADC0SS0, 0x20);
        ROM_IntPrioritySet(INT_PWM1_3, 0x40);
        ROM_IntPrioritySet(INT_UART0, 0x60);
        //ROM_IntPrioritySet(INT_I2C0, 0x80);
    
    
        HBridgeInit();
        ADCInit();
        //WatchdogInit();
        LimitInit();
        LEDInit();
        ButtonInit();
        BatRelayInit();
        strikerInit();
        UARTIFInit();
        ControllerInit();
    
        //ADS1015Init();		//deprecated no longer have external ADC
    
    
        //
        // Enable processor interrupts.
        //
    //    IntMasterEnable();
    
    	while(1)
    	{
    	    //
    	    // Enable processor interrupts.
    	    //
    	    IntMasterEnable();
    
    
    #ifdef MES896_DEBUG
    
    //		mes896.DEBUG_g_ulBatVolts = ADS1015BATVoltsSGet();
    //		mes896.DEBUG_g_ulCloseSpeedPot = ADS1015CloseSpeedGet();
    //		mes896.DEBUG_g_ul2InchOpenForcePot = ADS1015First2Get();
    //		mes896.DEBUG_g_ul2InchCloseForcePot = ADS1015Last2SGet();
    
    		UARTprintf("\n");
    		UARTprintf("******* CONTROLLER *******\n");
    		UARTprintf("OPERATE MODE :");UARTprintf(DEBUG_OPERATION_MODE[mes896.DEBUG_g_ulOperationMode]);
    		UARTprintf("\nCONTROL STATE:");UARTprintf(DEBUG_CONTROLLER_STATE[mes896.DEBUG_g_ulControllerState]);
    		UARTprintf("\nFAULT TYPE   :");UARTprintf(DEBUG_CONTROLLER_FAULTS[mes896.DEBUG_g_ulControllerFault]);
    		UARTprintf("\nDOOR STATE   :");UARTprintf(DEBUG_DOOR_STATE[mes896.DEBUG_g_ulDoorState]);
    		UARTprintf("\nDOOR CYCLE   :");UARTprintf(DEBUG_DOOR_CYCLES[mes896.DEBUG_g_ulDoorCycles]);
    		UARTprintf("\nOBST SENSOR  :");UARTprintf(DEBUG_OBSTRUCTION_SENSOR[mes896.DEBUG_g_ulObstructionSensor]);
    		UARTprintf("\nOPEN DELAY   :");UARTprintf(DEBUG_OPEN_DOOR_DELAY[mes896.DEBUG_g_ulOpenDelay]);
    		UARTprintf("\n********** MOTOR *********\n");
    		mes896.DEBUG_g_fBatVolts = (((mes896.DEBUG_g_ulBatVolts*2475.0)/4096.0)*.001);	//Convert ADC to Volts
    		mes896.DEBUG_g_ulBatVolts = mes896.DEBUG_g_fBatVolts*100;	//Remove Decimal
    		mtemp = (mes896.DEBUG_g_ulBatVolts / 100);					//Get whole Number
    		mdec = (mes896.DEBUG_g_ulBatVolts - (mtemp*100));			//Get Decimal Number
    		UARTprintf("BATTERY V:%d",mtemp);
    		UARTprintf(".");
    		UARTprintf("%d",mdec);
    		UARTprintf(" V\n");
    		UARTprintf("HBRIDGE V:%d \n",mes896.DEBUG_g_lHbridgeV);
    		UARTprintf("PWM ON   :%d \n",mes896.DEBUG_g_ulOn);
    		mes896.DEBUG_g_fBusVolts = VBusGet();
    		mes896.DEBUG_g_ulBusVolts = mes896.DEBUG_g_fBusVolts*100;	//Remove Decimal
    		mtemp = (mes896.DEBUG_g_ulBusVolts / 100);					//Get whole Number
    		mdec = (mes896.DEBUG_g_ulBusVolts - (mtemp*100));			//Get Decimal Number
    		UARTprintf("BUS VOLTS:%d",mtemp);
    		UARTprintf(".");
    		UARTprintf("%d",mdec);
    		UARTprintf(" V\n");
    		UARTprintf("MOTOR CZI:%d \n",mes896.DEBUG_g_usCurrentZero);
    		UARTprintf("MOTOR   I:%d [",mes896.DEBUG_g_ulMotorCurrent);
    		UARTprintf("%d] ",mes896.DEBUG_g_ulMotorRawCount);
    		mes896.DEBUG_g_fMotorCurrent = (float)(((mes896.DEBUG_g_ulMotorRawCount)*(3.0/1023.0)-1.65)/0.11);
    		if (mes896.DEBUG_g_fMotorCurrent < 0)
    		{
    			ms = 1;
    			mes896.DEBUG_g_fMotorCurrent = (-1)* mes896.DEBUG_g_fMotorCurrent;
    			UARTprintf("-");
    		}
    		mI = mes896.DEBUG_g_fMotorCurrent*100;	//Remove Decimal
    		mtemp = (mI / 100);						//Get whole Number
    		mdec = (mI - (mtemp*100));				//Get Decimal Number
    		UARTprintf("%d",mtemp);
    		UARTprintf(".");
    		UARTprintf("%d",mdec);
    		UARTprintf(" Amps\n");
    		UARTprintf("MOTOR AVI:%d ",mes896.DEBUG_g_ulAveMotorCurrent);
    		mes896.DEBUG_g_fAveMotorCurrent = ((((float)(mes896.DEBUG_g_ulAveMotorCurrent)/100.0)));//*(3.0/1023.0)-1.65)/0.11);
    		if (mes896.DEBUG_g_fAveMotorCurrent < 0)
    		{
    			ms = 1;
    			mes896.DEBUG_g_fAveMotorCurrent = (-1)* mes896.DEBUG_g_fAveMotorCurrent;
    			UARTprintf("-");
    		}
    		mI = mes896.DEBUG_g_fAveMotorCurrent*100;	//Remove Decimal
    		mtemp = (mI / 100);							//Get whole Number
    		mdec = (mI - (mtemp*100));					//Get Decimal Number
    		UARTprintf("%d",mtemp);
    		UARTprintf(".");
    		UARTprintf("%d",mdec);
    		UARTprintf(" Amps\n");
    		UARTprintf("COMMAND I:");
    //		mes896.DEBUG_g_fCommandCurrent = (float)(((mes896.DEBUG_g_ulCommandCurrent)));
    //		if (mes896.DEBUG_g_fCommandCurrent < 0)
    //		{
    //			ms = 1;
    //			mes896.DEBUG_g_fCommandCurrent = (-1)* mes896.DEBUG_g_fCommandCurrent;
    //			UARTprintf("-");
    //		}
    		mI = mes896.DEBUG_g_fCommandCurrent*100;	//Remove Decimal
    		mtemp = (mI / 100);							//Get whole Number
    		mdec = (mI - (mtemp*100));					//Get Decimal Number
    		UARTprintf("%d",mtemp);
    		UARTprintf(".");
    		UARTprintf("%d",mdec);
    		UARTprintf(" Amps\n");
    
    		UARTprintf("MOTOR DIR:");
    		UARTprintf(DEBUG_MOTOR_STATE[mes896.DEBUG_g_ulMotorState]);
    		UARTprintf("\n****** POT SETTINGS ******\n");
    		UARTprintf("2 IN OPEN    :%d \n",mes896.DEBUG_g_ul2InchOpenForcePot);
    		UARTprintf("OPEN TIME    :%d [",mes896.DEBUG_g_ulOpenTimePot);
    		UARTprintf("%d] ",mes896.DEBUG_g_ulOpenTimePotRaw);UARTprintf("sec.\n");
    		UARTprintf("OPEN SPEED   :%d [",mes896.DEBUG_g_ulOpenSpeedPot);
    		UARTprintf("%d]\n",mes896.DEBUG_g_ulOpenSpeedPotRaw);
    		UARTprintf("CLOSE SPEED  :%d \n",mes896.DEBUG_g_ulCloseSpeedPot);
    		UARTprintf("HOLED CURRENT:%d [",mes896.DEBUG_g_ulHoldCurrentPot);
    		UARTprintf("%d]\n",mes896.DEBUG_g_ulHoldCurrentPotRaw);
    		UARTprintf("FORCE        :%d [",mes896.DEBUG_g_ulForcePot);
    		UARTprintf("%d]\n",mes896.DEBUG_g_ulForcePotRaw);
    		UARTprintf("2 IN CLOSE   :%d \n",mes896.DEBUG_g_ul2InchCloseForcePot);
    		UARTprintf("****** TEMPERATURE *******\n");
    		mes896.DEBUG_g_fTempSensor = TemperatureGet();
    		mes896.DEBUG_g_ulTempSensor = (mes896.DEBUG_g_fTempSensor/256)*100;	//Remove Decimal
    		mtemp = (mes896.DEBUG_g_ulTempSensor / 100);					//Get whole Number
    		mdec = (mes896.DEBUG_g_ulTempSensor - (mtemp*100));				//Get Decimal Number
    		UARTprintf("TEMPERATURE  :%d",mtemp);
    		UARTprintf(".");
    		UARTprintf("%d",mdec);
    		UARTprintf(" C\n");
    		UARTprintf("**************************\n");
    		UARTprintf("\n");
    
    		for (mt = 0; mt < 65535; mt++);
    //		for (mt = 0; mt < 65535; mt++);
    //		for (mt = 0; mt < 65535; mt++);
    #else
            //
            // Put the processor to sleep until the next interrupt.
            //
    #ifndef DEBUG
            SysCtlSleep();
    #endif
    
    #endif
    	}
    }
    

    3) The pwm pheripheral 1 is configure in hbridge.c. 

    6076.hbridge.c
    /*
     * hbridge.c
     *
     *  Created on: Apr 29, 2013
     *      Author: Moises
     *
     *
     *		Issue:	 2.0
     *      Version: 1.0
     *      Project: Savaria's motor controller
     *
     *		Date: 8/28/2013
     *      upgrade: Move Code from StellarisWare to TivaWare because new boards use New Tiva C controller
     *
     *
     */
    
    #include <stdint.h>
    #include <stdbool.h>		//These are require because of C99 Coding standard
    
    #include "inc/hw_gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom_map.h"
    
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_pwm.h"
    #include "inc/hw_types.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pwm.h"
    #include "driverlib/rom.h"
    #include "driverlib/sysctl.h"
    #include "can_proto.h"
    #include "constants.h"
    #include "controller.h"
    #include "hbridge.h"
    #include "limit.h"
    #include "io.h"
    #include "debug_msg.h"
    
    
    extern MOTOR_CONTROLLER mes896;
    
    //*****************************************************************************
    //
    // Alias defines for the generators to relate them to the H-bridge hardware.
    //
    // Had to move up the PWM GEN by 1 because PWM0 and PWM1 we could not use on TIVA C
    // because we needed the ADC input channel.  So we are using pairs PWM2 and PWM3 on GEN1
    // and PWM4 and PWM5 on GEN2.  Time Base is on GEN3.
    //
    //*****************************************************************************
    #define GEN_M_PLUS              PWM_GEN_1
    #define GEN_M_MINUS             PWM_GEN_2
    #define GEN_TIMING              PWM_GEN_3
    #define GEN_M_PLUS_BIT          PWM_GEN_1_BIT
    #define GEN_M_MINUS_BIT         PWM_GEN_2_BIT
    
    //*****************************************************************************
    //
    // Alias defines for the comparator register offsets.
    //
    //*****************************************************************************
    #define M_PLUS_CMP              PWM_O_1_CMPA
    #define M_MINUS_CMP             PWM_O_2_CMPA
    #define M_ADC_CMP               PWM_O_1_CMPB
    
    //*****************************************************************************
    //
    // Alias defines for the generator register offset.
    //
    //*****************************************************************************
    #define M_PLUS_GENH             PWM_O_1_GENA	//PWM_O_0_GENA
    #define M_PLUS_GENL             PWM_O_1_GENB	//PWM_O_0_GENB
    #define M_MINUS_GENH            PWM_O_2_GENA	//PWM_O_1_GENA
    #define M_MINUS_GENL            PWM_O_2_GENB	//PWM_O_1_GENB
    
    //*****************************************************************************
    //
    // The value to program into a PWMxGEN for the high side to make it be on all
    // the time.  This must be coupled by setting the high side comparator to
    // IGNORE (otherwise it will continue to generate pulses).
    //
    //*****************************************************************************
    #define HIGH_SIDE_ON            (PWM_X_GENA_ACTZERO_ONE |                     \
                                     PWM_X_GENA_ACTCMPAU_INV |                    \
                                     PWM_X_GENA_ACTCMPAD_INV)
    
    //*****************************************************************************
    //
    // The value to program into a PWMxGEN for the high side to make it produce
    // pulses.  This must be coupled by setting the high side comparator to an
    // appropriate value to control the width of the pulse.
    //
    //*****************************************************************************
    #define HIGH_SIDE_PULSE         (PWM_X_GENA_ACTZERO_ZERO |                    \
                                     PWM_X_GENA_ACTCMPAU_INV |                    \
                                     PWM_X_GENA_ACTCMPAD_INV)
    
    //*****************************************************************************
    //
    // The value to program into a PWMxGEN for the high side to make it be off all
    // the time.  This must be coupled by setting the high side comparator to
    // IGNORE (otherwise it will continue to generate pulses).
    //
    //*****************************************************************************
    #define HIGH_SIDE_OFF           (PWM_X_GENA_ACTZERO_ZERO |                    \
                                     PWM_X_GENA_ACTCMPAU_INV |                    \
                                     PWM_X_GENA_ACTCMPAD_INV)
    
    //*****************************************************************************
    //
    // The value to program into a PWMxGEN for the low side to make it be on all
    // the time.  This must be coupled by setting the low side comparator to IGNORE
    // (otherwise it will continue to generate pulses).
    //
    //*****************************************************************************
    #define LOW_SIDE_ON             (PWM_X_GENA_ACTZERO_ONE |                     \
                                     PWM_X_GENA_ACTCMPAU_INV |                    \
                                     PWM_X_GENA_ACTCMPAD_INV)
    
    //*****************************************************************************
    //
    // The value to program into a PWMxGEN for the low side to make it produce
    // pulses.  This must be coupled by setting the low side comparator to an
    // appropriate value to control the width of the pulse.
    //
    //*****************************************************************************
    #define LOW_SIDE_PULSE          (PWM_X_GENA_ACTZERO_ONE |                     \
                                     PWM_X_GENA_ACTCMPAU_INV |                    \
                                     PWM_X_GENA_ACTCMPAD_INV)
    
    //*****************************************************************************
    //
    // The value to program into a PWMxGEN for the low side to make it be off all
    // the time.  This must be coupled by setting the low side comparator to IGNORE
    // (otherwise it will continue to generate pulses).
    //
    //*****************************************************************************
    #define LOW_SIDE_OFF            (PWM_X_GENA_ACTZERO_ZERO |                    \
                                     PWM_X_GENA_ACTCMPAU_INV |                    \
                                     PWM_X_GENA_ACTCMPAD_INV)
    
    //*****************************************************************************
    //
    // The value to program into a comparator (high or low side) in order to make
    // the comparator be ignored.  Since the comparators are ignored when they
    // trigger at the same time as the zero event, they are set to zero.
    //
    //*****************************************************************************
    #define IGNORE                  0
    
    //*****************************************************************************
    //
    // The number of clocks prior to the high-side falling edge that the ADC is
    // triggered.  This must be sufficiently large to allow the sample-and-hold
    // circuit to capture the current reading prior to the injected switching noise
    // at the falling edge.
    //
    //*****************************************************************************
    #define ADC_SAMPLE_DELTA        16
    
    //*****************************************************************************
    //
    // The current output voltage to the H-bridge.  The volatile is not strictly
    // required but is used in EW-ARM to workaround some versions of the compiler
    // trying to be too clever (resulting in incorrectly generated machine code).
    //
    //*****************************************************************************
    #ifdef ewarm
    static volatile int32_t g_lHBridgeV = 0;
    #else
    static int32_t g_lHBridgeV = 0;
    #endif
    
    
    //*****************************************************************************
    //
    // The maximum output voltage to the H-bridge.
    //
    //*****************************************************************************
    static int32_t g_lHBridgeVMax = 32767;
    
    //*****************************************************************************
    //
    // The configuration of the coast setting.  By default, coast.
    //
    //*****************************************************************************
    static uint32_t g_ulHBridgeBrakeCoast = HBRIDGE_COAST;
    //static unsigned long g_ulHBridgeBrakeCoast = HBRIDGE_BRAKE;
    
    //*****************************************************************************
    //
    // Determines if the drive is configured for brake or coast mode.
    //
    //*****************************************************************************
    static uint32_t HBridgeBrakeCoastMode(void)
    {
        //
        // See if the drive is configured for braking or coasting.
        //
        if((g_ulHBridgeBrakeCoast == HBRIDGE_COAST))
        {
            //
            // The drive is configured for coast mode.
            //
            return(HBRIDGE_COAST);
        }
        else
        {
            //
            // The drive is configured for brake mode.
            //
            return(HBRIDGE_BRAKE);
        }
    }
    
    //*****************************************************************************
    //
    // Sets the H-bridge into either brake or coast mode, based on the current
    // configuration.  Note that coast is also referred to as fast decay and brake
    // is also referred to as slow decay.
    //
    //*****************************************************************************
    static void HBridgeBrakeCoast(uint32_t ulMode)
    {
        //
        // The PWM comparison registers are not needed when braking or coasting, so
        // move them to a place where they will be ignored by the hardware.
        //
        HWREG(PWM1_BASE + M_PLUS_CMP) = IGNORE;
        HWREG(PWM1_BASE + M_MINUS_CMP) = IGNORE;
        HWREG(PWM1_BASE + M_ADC_CMP) = ADC_SAMPLE_DELTA;
    
        //
        // See if the drive is configured for braking or coasting.
        //
        if(ulMode == HBRIDGE_COAST)
        {
            //
            // Place the H-bridge into coast mode.
            //
            HWREG(PWM1_BASE + M_PLUS_GENH) = HIGH_SIDE_OFF;
            HWREG(PWM1_BASE + M_PLUS_GENL) = LOW_SIDE_OFF;
            HWREG(PWM1_BASE + M_MINUS_GENH) = HIGH_SIDE_OFF;
            HWREG(PWM1_BASE + M_MINUS_GENL) = LOW_SIDE_OFF;
        }
        else
        {
            //
            // Place the H-bridge into brake mode.
            //
            HWREG(PWM1_BASE + M_PLUS_GENH) = HIGH_SIDE_OFF;
            HWREG(PWM1_BASE + M_PLUS_GENL) = LOW_SIDE_ON;
            HWREG(PWM1_BASE + M_MINUS_GENH) = HIGH_SIDE_OFF;
            HWREG(PWM1_BASE + M_MINUS_GENL) = LOW_SIDE_ON;
        }
    }
    
    //*****************************************************************************
    //
    // Resets the gate driver, clearing any latched fault conditions.
    //
    //*****************************************************************************
    void HBridgeGateDriverReset(void)
    {
        //
        // Drive the gate driver reset signal low.
        //
    //    ROM_GPIOPinWrite(GATE_RESET_PORT, GATE_RESET_PIN, 0);
    	MAP_GPIOPinWrite(GATE_RESET_PORT, GATE_RESET_PIN, 0);
    
        //
        // Delay for 1us.
        //
        SysCtlDelay(SYSCLK / (1000000 * 3));
    
        //
        // Drive the gate driver reset signal high.
        //
    //    ROM_GPIOPinWrite(GATE_RESET_PORT, GATE_RESET_PIN, GATE_RESET_PIN);
        MAP_GPIOPinWrite(GATE_RESET_PORT, GATE_RESET_PIN, GATE_RESET_PIN);
    }
    
    //*****************************************************************************
    //
    // Initializes the H-Brige interface.
    //
    //*****************************************************************************
    void HBridgeInit(void)
    {
        //
        // Initialize the H-bridge PWM outputs.
        //
        ROM_GPIOPinTypePWM(HBRIDGE_AHI_PORT, HBRIDGE_AHI_PIN);	//M1PWM2
        ROM_GPIOPinTypePWM(HBRIDGE_ALO_PORT, HBRIDGE_ALO_PIN);	//M1PWM3
        ROM_GPIOPinTypePWM(HBRIDGE_BHI_PORT, HBRIDGE_BHI_PIN);	//M1PWM4
        ROM_GPIOPinTypePWM(HBRIDGE_BLO_PORT, HBRIDGE_BLO_PIN);	//M1PWM5
    
        //
        // Initialize the gate driver control signals.
        //
    //    ROM_GPIOPinTypeGPIOOutput(GATE_RESET_PORT, GATE_RESET_PIN);
    //    ROM_GPIOPinTypeGPIOInput(GATE_FAULT_PORT, GATE_FAULT_PIN);
    
        MAP_GPIOPinTypeGPIOOutput(GATE_RESET_PORT, GATE_RESET_PIN);   // Enable port PF3 for GPIOOutput
        MAP_GPIOPinTypeGPIOInput(GATE_FAULT_PORT, GATE_FAULT_PIN);    // Enable port PF4 for GPIOOutput
    
    
        //
        // Reset the gate driver.
        //
        HBridgeGateDriverReset();
    
        //
        // Configure the PWM generators.
        //
        ROM_PWMGenConfigure(PWM1_BASE, GEN_M_PLUS,
                            (PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_SYNC |
                             PWM_GEN_MODE_DBG_STOP));
        ROM_PWMGenConfigure(PWM1_BASE, GEN_M_MINUS,
                            (PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_SYNC |
                             PWM_GEN_MODE_DBG_STOP));
        ROM_PWMGenConfigure(PWM1_BASE, GEN_TIMING,
                            PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DBG_STOP);
    
        //
        // Set the counter period in each generator.
        //
        ROM_PWMGenPeriodSet(PWM1_BASE, GEN_M_PLUS, SYSCLK_PER_PWM_PERIOD);
        ROM_PWMGenPeriodSet(PWM1_BASE, GEN_M_MINUS, SYSCLK_PER_PWM_PERIOD);
        ROM_PWMGenPeriodSet(PWM1_BASE, GEN_TIMING, SYSCLK_PER_UPDATE);
    
        //
        // Set the default output.  The value for this depends on the brake/coast
        // setting.
        //
        HBridgeBrakeCoastSet(HBRIDGE_BRAKE);
        HBridgeBrakeCoast(HBridgeBrakeCoastMode());
    
        //
        // Set the trigger enable for the M+ generator to initiate the ADC sample
        // sequence.  Set the interrupt enable for the timing generator.
        //
        ROM_PWMGenIntTrigEnable(PWM1_BASE, GEN_M_PLUS, PWM_TR_CNT_BD);
        ROM_PWMGenIntTrigEnable(PWM1_BASE, GEN_TIMING, PWM_INT_CNT_ZERO);
    
        //
        // Enable the PWM counters in the generators specified.
        //
        ROM_PWMGenEnable(PWM1_BASE, GEN_M_PLUS);
        ROM_PWMGenEnable(PWM1_BASE, GEN_M_MINUS);
        ROM_PWMGenEnable(PWM1_BASE, GEN_TIMING);
    
        //
        // Synchronize the counters in all generators.
        //
        ROM_PWMSyncTimeBase(PWM1_BASE, GEN_M_PLUS_BIT | GEN_M_MINUS_BIT);
    
        //
        // If the debugger stops the system, the PWM outputs should be shut down,
        // otherwise, they could be left in a full on state, which will result in
        // shoot-through.  Instead, the motor is put into coast mode while the
        // processor is halted by the debugger.
        //
        ROM_PWMOutputFault(PWM1_BASE, (PWM_OUT_2_BIT | PWM_OUT_3_BIT |
                                       PWM_OUT_4_BIT | PWM_OUT_5_BIT), true);
    
        //
        // Force a global sync so that any pending updates to CMPA, GENA, or GENB
        // are handled.
        //
        ROM_PWMSyncUpdate(PWM1_BASE, GEN_M_PLUS_BIT | GEN_M_MINUS_BIT);
    
        //
        // Enable the output signals of the PWM unit.
        //
        ROM_PWMOutputState(PWM1_BASE, (PWM_OUT_2_BIT | PWM_OUT_3_BIT |
                                       PWM_OUT_4_BIT | PWM_OUT_5_BIT), true);
    
        //
        // Enable the timing interrupt.
        //
        ROM_PWMIntEnable(PWM1_BASE, PWM_GEN_3_BIT);
        ROM_SysCtlDelay(10);							//On Tiva 5 Cycles is needed before using Pheripheral
        ROM_IntEnable(INT_PWM1_3);						//GEN 3 Time Base
        ROM_SysCtlDelay(10);
        //ROM_PWMGenIntTrigEnable(PWM1_BASE, PWM_GEN_3,PWM_INT_CNT_ZERO | PWM_TR_CNT_LOAD);
    
        //
        // Clear Interrupt Intializing
        //
        ROM_PWMGenIntClear(PWM1_BASE, PWM_GEN_3, PWM_INT_CNT_ZERO);
    }
    
    //*****************************************************************************
    //
    // Sets the maximum H-bridge output voltage.  This is used to scale the
    // requested voltage. 8.8 Fixed Format
    //
    // On Savaria's board we have change the Voltage Divider to sense the Bridge Bus Voltage
    // -Original was 11K/1K to give a factor of 12.
    // -New is now 145K/20K to give a factor of 8.25. Will change this again to even number
    //      sucha as 200K/20K or 100K/10K to give factor of 10.
    //*****************************************************************************
    void HBridgeVoltageMaxSet(int32_t lVoltage)
    {
        //
        // Save the new maximum output voltage.  This will be applied to the
        // H-bridge on the next H-bridge tick.
        //
        g_lHBridgeVMax = (lVoltage * 32767) / ((12) * 256);
    }
    
    //*****************************************************************************
    //
    // Gets the maximum H-bridge output voltage. 8.8 Fixed format
    //
    // On Savaria's board we have change the Voltage Divider to sense the Bridge Bus Voltage
    // -Original was 11K/1K to give a factor of 12.
    // -New is now 145K/20K to give a factor of 8.25. Will change this again to even number
    //      sucha as 200K/20K or 100K/10K to give factor of 10.
    // - Whent back to original of 11/1 or factor of 12 (1K/1K + 11K)
    //*****************************************************************************
    int32_t HBridgeVoltageMaxGet(void)
    {
        //
        // Return the maximum output voltage.
        //
        return((g_lHBridgeVMax * (12) * 256) / 32767);
    }
    
    //*****************************************************************************
    //
    // Sets the H-bridge output voltage.
    //
    //*****************************************************************************
    void
    HBridgeVoltageSet(int32_t lVoltage)
    {
        //
        // Save the new output voltage.  This will be applied to the H-bridge on
        // the next H-bridge tick.
        //
        g_lHBridgeV = lVoltage;
    
        //update debug variable
        mes896.DEBUG_g_lHbridgeV = g_lHBridgeV;
    }
    
    //*****************************************************************************
    //
    // Sets the H-bridge brake/coast configuration.
    //
    //*****************************************************************************
    void HBridgeBrakeCoastSet(uint32_t ulState)
    {
        //
        // Save the new brake/coast configuration.  This will be applied on the
        // next H-bridge tick in which the motor is in neutral.
        //
        g_ulHBridgeBrakeCoast = ulState;
    }
    
    //*****************************************************************************
    //
    // Gets the H-bridge brake/coast configuration.
    //
    //*****************************************************************************
    uint32_t HBridgeBrakeCoastGet(void)
    {
        //
        // Return the brake/coast configuration.
        //
        return(g_ulHBridgeBrakeCoast);
    }
    
    //*****************************************************************************
    //
    // Handles the periodic update to the H-bridge output.
    //
    //*****************************************************************************
    void HBridgeTick(void)
    {
        uint32_t ulOn, ulMode;
    
        //
        // See if there is a fault condition indicated by the gate driver.
        //
        if(ROM_GPIOPinRead(GATE_FAULT_PORT, GATE_FAULT_PIN) == 0)
        {
            //
            // Indicate that there is a gate driver fault.
            //
            ControllerFaultSignal(LM_FAULT_GATE_DRIVE);
        }
    
        //
        // Determine if the drive is in coast mode.
        //
        ulMode = HBridgeBrakeCoastMode();
    
        //
        // See if the output voltage should be zero (in other words, neutral).
        //
        if(g_lHBridgeV == 0)
        {
            //
            // Set the H-bridge to coast mode.  This is done every
            // interrupt to handle the cases where the jumper is being used and it
            // is being driven by an external source (such as another
            // microcontroller).
            //
            HBridgeBrakeCoast(ulMode);
        }
    
        //
        // See if the output voltage is negative (in other words, reverse).
        //
        else if(g_lHBridgeV < 0)
        {
            //
            // Make sure that the limit switches allow the motor to run in reverse.
            //
            if(LimitCloseDoorOK())
            {
                //
                // Compute the number of clocks that the high side MOSFET should be
                // turned on.
                //
                ulOn = (((((0 - g_lHBridgeV) * g_lHBridgeVMax) / 32767) *
                         SYSCLK_PER_PWM_PERIOD) / 32767);
    
    #ifdef MES896_DEBUG
                mes896.DEBUG_g_ulOn = ulOn;
                mes896.DEBUG_g_ulMotorState = ID_REVERSE;
    #endif
    
                //
                // See if the high side MOSFET should be on for most of the PWM
                // period.
                //
                if(ulOn >= (SYSCLK_PER_PWM_PERIOD - PWM_MIN_WIDTH))
                {
                    //
                    // No switching is required; simply leave the low side of the
                    // positive terminal and the high side of the negative terminal
                    // on the entire time.
                    //
                    HWREG(PWM1_BASE + M_PLUS_CMP) = IGNORE;
                    HWREG(PWM1_BASE + M_MINUS_CMP) = IGNORE;
                    HWREG(PWM1_BASE + M_ADC_CMP) = ADC_SAMPLE_DELTA;
                    HWREG(PWM1_BASE + M_PLUS_GENH) = HIGH_SIDE_OFF;
                    HWREG(PWM1_BASE + M_PLUS_GENL) = LOW_SIDE_ON;
                    HWREG(PWM1_BASE + M_MINUS_GENH) = HIGH_SIDE_ON;
                    HWREG(PWM1_BASE + M_MINUS_GENL) = LOW_SIDE_OFF;
                }
    
                //
                // Otherwise, see if the high side MOSFET should be off for most of
                // the PWM period.
                //
                else if(ulOn < PWM_MIN_WIDTH)
                {
                    //
                    // No switching is required; simply put the H-bridge into brake
                    // or coast mode as configured.
                    //
                    HBridgeBrakeCoast(ulMode);
    
    #ifdef MES896_DEBUG
                    mes896.DEBUG_g_ulMotorState = ID_STOPPED;
    #endif
                }
    
                //
                // Otherwise, the output should be on only part of the time.
                //
                else
                {
                    //
                    // Turn on the PWM high side output for the specified time
                    // and the low side output on for the remaining time.
                    //
                    HWREG(PWM1_BASE + M_PLUS_CMP) = IGNORE;
                    HWREG(PWM1_BASE + M_MINUS_CMP) =
                        (SYSCLK_PER_PWM_PERIOD - ulOn) / 2;
                    HWREG(PWM1_BASE + M_ADC_CMP) =
                        ((SYSCLK_PER_PWM_PERIOD - ulOn) / 2) + ADC_SAMPLE_DELTA;
                    HWREG(PWM1_BASE + M_PLUS_GENH) = HIGH_SIDE_OFF;
                    HWREG(PWM1_BASE + M_PLUS_GENL) = LOW_SIDE_ON;
                    HWREG(PWM1_BASE + M_MINUS_GENH) = HIGH_SIDE_PULSE;
                    HWREG(PWM1_BASE + M_MINUS_GENL) = LOW_SIDE_PULSE;
                }
            }
            else
            {
                //
                // The limit switches do not allow the motor to be driven in
                // reverse, so set the H-bridge to brake or coast mode.
                //
                HBridgeBrakeCoast(ulMode);
            }
        }
    
    
        //
        // Otherwise, the output voltage is positive (in other words, forward).
        //
        else
        {
            //
            // Make sure that the limit switches allow the motor to run forward.
            //
            if(LimitOpenDoorOK())
            //if(1)
            {
                //
                // Compute the number of clocks that the high side MOSFET should be
                // turned on.
                //
                ulOn = ((((g_lHBridgeV * g_lHBridgeVMax) / 32767) *
                         SYSCLK_PER_PWM_PERIOD) / 32767);
    
    #ifdef MES896_DEBUG
                mes896.DEBUG_g_ulOn = ulOn;
                mes896.DEBUG_g_ulMotorState = ID_FORWARD;
    #endif
    
                //
                // See if the high side MOSFET should be on for most of the PWM
                // period.
                //
                if(ulOn >= (SYSCLK_PER_PWM_PERIOD - PWM_MIN_WIDTH))
                {
                    //
                    // No switching is required; simply leave the high side of the
                    // positive terminal and the low side of the negative terminal
                    // on the entire time.
                    //
                    HWREG(PWM1_BASE + M_PLUS_CMP) = IGNORE;
                    HWREG(PWM1_BASE + M_MINUS_CMP) = IGNORE;
                    HWREG(PWM1_BASE + M_ADC_CMP) = ADC_SAMPLE_DELTA;
                    HWREG(PWM1_BASE + M_PLUS_GENH) = HIGH_SIDE_ON;
                    HWREG(PWM1_BASE + M_PLUS_GENL) = LOW_SIDE_OFF;
                    HWREG(PWM1_BASE + M_MINUS_GENH) = HIGH_SIDE_OFF;
                    HWREG(PWM1_BASE + M_MINUS_GENL) = LOW_SIDE_ON;
                }
    
                //
                // Otherwise, see if the high side MOSFET should be off for most of
                // the PWM period.
                //
                else if(ulOn < PWM_MIN_WIDTH)
                {
                    //
                    // No switching is required; simply put the H-bridge into brake
                    // or coast mode as configured.
                    //
                    HBridgeBrakeCoast(ulMode);
    
    #ifdef MES896_DEBUG
                    mes896.DEBUG_g_ulMotorState = ID_STOPPED;
    #endif
                }
    
                //
                // Otherwise, the output should be on only part of the time.
                //
                else
                {
                    //
                    // Turn on the PWM high side output for the specified time
                    // and the low side output on for the remaining time.
                    //
                    HWREG(PWM1_BASE + M_PLUS_CMP) =
                        (SYSCLK_PER_PWM_PERIOD - ulOn) / 2;
                    HWREG(PWM1_BASE + M_MINUS_CMP) = IGNORE;
                    HWREG(PWM1_BASE + M_ADC_CMP) =
                        ((SYSCLK_PER_PWM_PERIOD - ulOn) / 2) + ADC_SAMPLE_DELTA;
                    HWREG(PWM1_BASE + M_PLUS_GENH) = HIGH_SIDE_PULSE;
                    HWREG(PWM1_BASE + M_PLUS_GENL) = LOW_SIDE_PULSE;
                    HWREG(PWM1_BASE + M_MINUS_GENH) = HIGH_SIDE_OFF;
                    HWREG(PWM1_BASE + M_MINUS_GENL) = LOW_SIDE_ON;
                }
            }
            else
            {
                //
                // The limit switches do not allow the motor to be driven forward,
                // so set the H-bridge to brake or coast mode.
                //
                HBridgeBrakeCoast(ulMode);
            }
        }
    
        //
        // Force a global sync so that any pending updates to CMPA, GENA, or GENB
        // are handled.
        //
        ROM_PWMSyncUpdate(PWM1_BASE, GEN_M_PLUS_BIT | GEN_M_MINUS_BIT);
    }
    
    //*****************************************************************************
    //
    // Immediately places the H-bridge into neutral in preparation for a firmware
    // update.
    //
    //*****************************************************************************
    void HBridgeFirmwareUpdate(void)
    {
        //
        // Set the H-bridge to brake or coast mode.
        //
        HBridgeBrakeCoast(HBridgeBrakeCoastMode());
    
    #ifdef MES896_DEBUG
        mes896.DEBUG_g_ulMotorState = ID_STOPPED;
    #endif
    
        //
        // Force a global sync so that any pending updates to CMPA, GENA, or GENB
        // are handled.
        //
        ROM_PWMSyncUpdate(PWM1_BASE, GEN_M_PLUS_BIT | GEN_M_MINUS_BIT);
    }
    

    What have I missed that is causing the hard fault?

    Thanks.