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.

problem with TIVA TM4C123GH6PM PWM API

Other Parts Discussed in Thread: EK-TM4C123GXL, SW-TM4C

I'm using EK-TM4C123GXL Launch pad.

I'm using Keil MDK v5 as my IDE.

I'm trying to access PWM on this board.

I wrote the code using the pwm API provided.

my code is given below

---------------------------------------------------------------------------------------------------------------------

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_pwm.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/interrupt.h"
#include "driverlib/pwm.h"
#include "tm4c123gh6pm.h"

#define PWM1_BASE 0x40029000

int main()
{
	unsigned long PERIOD;
	
  PWMGenConfigure(PWM1_BASE, PWM_GEN_3,PWM_GEN_MODE_DOWN); // configure PWM1, generator 3, count down mode
	
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_3,0x0000018F);        // set pwm wave period
	PERIOD = PWMGenPeriodGet(PWM1_BASE, PWM_GEN_3);          // get the pwm wave period
	
	PWMGenEnable(PWM1_BASE, PWM_GEN_3);                      // Enables the timer/counter for a PWM generator block 3.
	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_7,0x00000063);       //Sets the pulse width for the specified PWM output.
	
	PWMOutputState(PWM1_BASE, PWM_OUT_7_BIT,true);           //Enables  PWM outputs.
	
	PWMOutputInvert(PWM1_BASE, PWM_OUT_7_BIT,false);         //Selects the inversion mode for PWM outputs.
	
	PWMOutputFaultLevel(PWM1_BASE, PWM_OUT_7_BIT,false);     //Specifies the level of PWM outputs suppressed in response to a fault
	                                                         // condition.
	
	PWMOutputFault(PWM1_BASE, PWM_OUT_7_BIT,false);          //Specifies the state of PWM outputs in response to a fault condition.
	
	while(1)
	{
	}
	
	
}

------------------------------------------------------------------------------------------------------------------------------

when compiled, the compiler gives error message as given below

---------------------------------------------------------------------------------------------------

compiling pwm_using_API.c...
pwm_using_API.c(42): warning:  #1-D: last line of file ends without a newline
  }
pwm_using_API.c(18): warning:  #550-D: variable "PERIOD" was set but never used
        unsigned long PERIOD;
pwm_using_API.c: 2 warnings, 0 errors
linking...
.\MPPT.axf: Error: L6218E: Undefined symbol PWMGenConfigure (referred from pwm_using_api.o).
.\MPPT.axf: Error: L6218E: Undefined symbol PWMGenEnable (referred from pwm_using_api.o).
.\MPPT.axf: Error: L6218E: Undefined symbol PWMGenPeriodGet (referred from pwm_using_api.o).
.\MPPT.axf: Error: L6218E: Undefined symbol PWMGenPeriodSet (referred from pwm_using_api.o).
.\MPPT.axf: Error: L6218E: Undefined symbol PWMOutputFault (referred from pwm_using_api.o).
.\MPPT.axf: Error: L6218E: Undefined symbol PWMOutputFaultLevel (referred from pwm_using_api.o).
.\MPPT.axf: Error: L6218E: Undefined symbol PWMOutputInvert (referred from pwm_using_api.o).
.\MPPT.axf: Error: L6218E: Undefined symbol PWMOutputState (referred from pwm_using_api.o).
.\MPPT.axf: Error: L6218E: Undefined symbol PWMPulseWidthSet (referred from pwm_using_api.o).
Not enough information to list image symbols.
Finished: 1 information, 0 warning and 9 error messages.
".\MPPT.axf" - 9 Error(s), 2 Warning(s).
Target not created

---------------------------------------------------------------------------------------------------------------------

please tell me how to fix this error.

 

  • Hello Chinmaya

    has the driverlib.lib been called during linking phase in Keil?

    Regards

    Amit

  • Amit,

    Amit Ashara said:

    Hello Chinmaya

    has the driverlib.lib been called during linking phase in Keil?

    Regards

    Amit

    I don't know how to check that.

    what ever the output window displayed, I copied the same thing in the 1st post above..

  • Hello Chinmaya,

    Right Click on your project -> Manage Project Items -> Project Items -> Groups -> Libraries

    there should be driverlib.lib

    If not then add it from Tivaware Installation's driverlib->rvmdk directory

    Regards

    Amit

  • Amit, 

    the previous problem is solved now. thank you.

    but the out put is still not coming. the LED is still off.

    during debugging, i saw the corresponding registers of PWM. no registers are updated with any value. 

    they are still in the reset state.

  • Hello Chinmaya

    1. You have to enable the PWM Peripheral by calling SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1)

    2. You have to enable the GPIO Port for which the pins need to be configured and then configure the pins for PWM operation.

    There is an example code for PWM in examples->peripheral->pwm that you can use as a reference

    Regards

    Amit

  • the controller is going to the " MemManage_Handler\ " in "startup.s" file.

    the handler says:

    --------------------------------------------------------------------------------------------------------------------------

    ;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.
    ;
    ;******************************************************************************
    HardFault_Handler\
                    PROC
                    EXPORT  HardFault_Handler         [WEAK]
                    B       .
                    ENDP
    
    MemManage_Handler\
                    PROC
                    EXPORT  MemManage_Handler         [WEAK]
                    B       .
                    ENDP

    --------------------------------------------------------------------------------------------------------------------------------

    what is the solution for this?

  • Hello Chinmaya,

    Is this after the changes?

    These are fault handlers. Can you send the updated Main Code so that it can be reviewed?

    Regards

    Amit

  • Amit Ashara said:

    Hello Chinmaya,

    Is this after the changes?

    These are fault handlers. Can you send the updated Main Code so that it can be reviewed?

    Regards

    Amit

    -----------------------------------------------------------------------------------------------------------------------------

    Amit,

    sorry for my late response. 

    today I tried the example code given in TIVA WARE  example -> pwm -> dead_band.c.

    I'm getting the same fault handler.

    the code is below:

    -------------------------------------------------------------------------------------------------------------------------------

    //*****************************************************************************
    //
    // dead_band.c - Example demonstrating the dead-band generator.
    //
    // Copyright (c) 2010-2013 Texas Instruments Incorporated.  All rights reserved.
    // Software License Agreement
    // 
    //*****************************************************************************
    
    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/hw_memmap.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/pwm.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    
    //*****************************************************************************
    //
    // Configure the PWM0 block with dead-band generation.  The example configures
    // the PWM0 block to generate a 25% duty cycle signal on PD0 with dead-band
    // generation.  This will produce a complement of PD0 on PD1 (75% duty cycle).
    // The dead-band generator is set to have a 10us or 160 cycle delay
    // (160cycles / 16Mhz = 10us) on the rising and falling edges of the PD0 PWM
    // signal.
    //
    //*****************************************************************************
    int
    main(void)
    {
       
        SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);
    
       
        SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
    
       
       
    
       
        SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
    
        //
        // For this example PWM0 is used with PortB Pins 6 and 7. 
      
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    
        
        GPIOPinConfigure(GPIO_PB6_M0PWM0);
        GPIOPinConfigure(GPIO_PB7_M0PWM1);
    
        
        GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);
        GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);
    
        
        PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN |
                        PWM_GEN_MODE_NO_SYNC);
    
        
        PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 64000);
    
        
        PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0,
                         PWMGenPeriodGet(PWM0_BASE, PWM_OUT_0) / 4);
    
        
        PWMDeadBandEnable(PWM0_BASE, PWM_GEN_0, 160, 160);
    
        
        PWMOutputState(PWM0_BASE, PWM_OUT_1_BIT | PWM_OUT_0_BIT, true);
    
        
        PWMGenEnable(PWM0_BASE, PWM_GEN_0);
    
        
        while(1)
        {
        
        }
    }
    

    ---------------------------------------------------------------------------------------------------------------------------

    it is going to the following fault handler in "startup.s" file

    ----------------------------------------------------------------

       319:                 ENDP 
       320:  
       321: MemManage_Handler\ 
       322:                 PROC 
       323:                 EXPORT  MemManage_Handler         [WEAK] 
    0x00000272 E7FE      B             HardFault_Handler (0x00000272)
       324:                 B       . 
       325:                 ENDP 
       326: BusFault_Handler\ 
       327:                 PROC 
       328:                 EXPORT  BusFault_Handler          [WEAK] 

    -----------------------------------------------------------------------------------------------------

    is this the problem with the code or the settings?

    I'm using Keil MDK v5 as my IDE.

  • Hello Chinmaya,

    When it hangs in the Bus Fault can you check the following two register and send me the content

    FAULTSTAT @ 0xE000ED28

    FAULTADDR @ 0xE000ED38

    This will help us figure out which access caused the Bus Fault

    Regards

    Amit

  • Amit Ashara said:

    Hello Chinmaya,

    When it hangs in the Bus Fault can you check the following two register and send me the content

    FAULTSTAT @ 0xE000ED28

    FAULTADDR @ 0xE000ED38

    This will help us figure out which access caused the Bus Fault

    Regards

    Amit

    Amit,

    FAULTSTAT @ 0xE000ED28:  0x00080000

    FAULTADDR @ 0xE000ED38: 0x00000000

    FAULTADDR @ 0xE000ED38:        0xE000EDF8

    i checked these through Memory Windows in Keil.

  • Hello Chinmaya,

    Can you zip and attach the project? This is a Co-Processor Fault which I would need to look into as it may involve project settings.

    Regards

    Amit

  • Amit,

    Today I installed TI CCS v5 and TIVA WARE.

    The API's are working properly on this platform.

    I felt it is difficult to work on Keil IDE for TIVA C series controllers.

    thanks to TI for providing a nice platform like CCS.

    I must thank you for your quick and sincere replays.

  • Hello Amit,

    Sorry for the off-topic but I'm stucked programming with Keil environment. I find some interesting code for Code Composer Studio (CSS) but I can't use it in Keil, could you give me some tips to do so?

    Specifically it's about this Labs at TM4C123G_LaunchPad_Workshop:

    http://processors.wiki.ti.com/index.php/Getting_Started_with_the_TIVA%E2%84%A2_C_Series_TM4C123G_LaunchPad

    and the labs that are inside:

    http://software-dl.ti.com/trainingTTO/trainingTTO_public_sw/GSW-TM4C123G-LaunchPad/TM4C123GLaunchPadWorkshopSetup.exe

    I'm trying to use the PWM code in Keil but I can't use it.

    Even better if you have code to run a PWM module in the EK-TM4C123GXL LaunchPad board.

    Thanks!

    Francisco

  • Hello Francisco,

    There is a PWM example in the TIVAWare Installation

    C:\ti\TivaWare_C_Series-2.1.0.12573\examples\peripherals\pwm

    May be you can refer to the same here.

    Regards

    Amit

  • Hi Amit,

    I just downloaded this: SW-EK-TM4C123GXL-2.1.0.12573.exe EK-TM4C123GXL Kit Software 33056K

    from http://software-dl.ti.com/tiva-c/SW-TM4C/latest/index_FDS.html

    I hope it's OK. I'll check it and tell you back. Thanks!

    Francisco

  • Hi,

         I want to generate PWM signals for Tiva C series using the same API that Chinmaya mentioned in this forum.But I got same error(ie undefined symbol) that mentioned, eventhough I had added the driverlib.lib as Amit's post.Can anybody suggest solution for this

    Build target 'driverlib'
    linking...
    .\rvmdk\driverlib.axf: Error: L6218E: Undefined symbol PWMGenConfigure (referred from pwmtimer.o).
    .\rvmdk\driverlib.axf: Error: L6218E: Undefined symbol PWMGenEnable (referred from pwmtimer.o).
    .\rvmdk\driverlib.axf: Error: L6218E: Undefined symbol PWMGenPeriodGet (referred from pwmtimer.o).
    .\rvmdk\driverlib.axf: Error: L6218E: Undefined symbol PWMGenPeriodSet (referred from pwmtimer.o).
    .\rvmdk\driverlib.axf: Error: L6218E: Undefined symbol PWMOutputFault (referred from pwmtimer.o).
    .\rvmdk\driverlib.axf: Error: L6218E: Undefined symbol PWMOutputFaultLevel (referred from pwmtimer.o).
    .\rvmdk\driverlib.axf: Error: L6218E: Undefined symbol PWMOutputInvert (referred from pwmtimer.o).
    .\rvmdk\driverlib.axf: Error: L6218E: Undefined symbol PWMOutputState (referred from pwmtimer.o).
    .\rvmdk\driverlib.axf: Error: L6218E: Undefined symbol PWMPulseWidthSet (referred from pwmtimer.o).
    Finished: 0 information, 0 warning and 9 error messages.
    ".\rvmdk\driverlib.axf" - 9 Error(s), 0 Warning(s).
    Target not created

  • Hello Nithin,

    Can you send the project database (zipped)? Looking at the message it seems that pwm.h may not have been built in the driverlib.lib during link phase.

    Regards

    Amit

  • Hello nithin,

    copy the folders "driverlib" and "inc" into your workspace.

    also include following in your code.

    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/sysctl.h"
    #include "inc/tm4c123gh6pm.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/gpio.h"
    #include "driverlib/timer.h"
    #include "driverlib/pwm.h"
    #include "inc/hw_gpio.h"
    #include "driverlib/pin_map.h"

  • When you say to add driverlib.lib to the worskpace, does it mean we should manually copy the driverlib folder with all the driver header files as well? Also, should driverlib.lib be put inside a folder named driverlib? Since the include statements are, 

    #include "driverlib/foo.h"