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.

TM4C123 with CC3100 and PWM

Other Parts Discussed in Thread: CC3100, CC3200, TM4C123GH6PM

My group is attempting to use the wireless module CC3100 with the TM4C123.  So far it has been a success.  We are able to pass commands from one CC3100 module to another.  The problem is that I would like to control multiple pwm signals on one TM4C which is receiving commands from the another CC3100 module.  It seems that the PWM and timers altogether have been disabled for the most part.  A function was called called "stopWDT()".  Looking deeper into the function I found the following code:

Is it possible to use PWM and the wireless module at the same time?  Is the CC3200 a better choice for implementing multiple PWM signals while simultaneously communicating over WiFi?

void stopWDT()

{

}

int registerInterruptHandler(P_EVENT_HANDLER InterruptHdl , void* pValue)

{

pIrqEventHandler = InterruptHdl;

return 0;

}

void CC3100_disable()

{

ROM_GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4, PIN_LOW);

}

void CC3100_enable()

{

ROM_GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4, PIN_HIGH);

}

void CC3100_InterruptEnable()

{

GPIOIntEnable(GPIO_PORTB_BASE,GPIO_PIN_2);

#ifdef SL_IF_TYPE_UART

ROM_UARTIntEnable(UART1_BASE, UART_INT_RX);

#endif

}

void CC3100_InterruptDisable()

{

GPIOIntDisable(GPIO_PORTB_BASE,GPIO_PIN_2);

#ifdef SL_IF_TYPE_UART

ROM_UARTIntDisable(UART1_BASE, UART_INT_RX);

#endif

}

  • Michael Thomason said:
    seems the PWM and timers altogether have been disabled for the most part.

    W/in the code you've presented I find no PWM nor Timer references.

    Might you describe how you've come to your, "Disabling of PWM & Timers" conclusion?   Might it be - instead - that both have been disabled elsewhere (possibly to reduce current draw) and simply (await) your peripheral enabling?   A quick/dirty test (my favorite) would result from your enabling any one of the MCU's (free) Timers - ordering it into PWM mode - and then observing its output upon CCPx (Timer) pin.

    We use another's RF module - thus "don't know" 3100 nor 3200 inner workings...

  • Hi Michael,

    The void stopWDT() is an empty function and has nothing to do with the other C functions that you posted here. I am a little bit familiar with this, because I have been reviewing the CC3100 SDK. If you are using one of the example programs for Tiva MCU + CC3100, most probably the Timers and PWM are not enabled by default. I would suggest learning how to enable Timers and PWM from Tivaware example first.

    TI CC3200 also has PWM and Timers. You need to check at datasheets if TI CC3200 would be a better choice compared to Tiva MCU + CC3100.

    - kel
  • cb1_mobile said:
    instead - that both (Timer & PWM) have been disabled elsewhere (possibly to reduce current draw) and simply (await) your peripheral enabling? 

    Hi Kel,

    Thanks for your confirmation of my (much earlier) suspicion.   Appears your "little bit familiarity" combined w/my "no familiarity, whatsoever" have agreed...

  • Thank you everyone for your responses and help. I am new to the forums and hope this goes to everyone. I tested my code ensuring its successful operation of pwm and timers before integrating it with the code example found for the CC3100. I am sure that I have made some mistake or missed something though. I am new to the platform and Murphy's Laws are strong.

    None of the timers seem to work. I can not get the LEDs on PORTF blink. I have been digging deeper into the code and can't seem to figure out how to re-enable them. Here is more of the code. The full program is pretty large. This section should enable timer0_ISR, I believed and has worked on other programs. It will now not work at all. I find the same issue with timer one and all pwm output. Is it possible to disable the operation of timers or is there something I am missing for initialization? Would it be possible for the CC3100 be grounding out pins that would be counteracting the output of the pwm? I am going to look back at all the pin states in the example code used for piggybacking. Why would that cause the onboard LEDs to not operate as well.   

    Please excuse me editing to include code I forgot to paste.
     
    #include <stdio.h>
    #include <math.h>
    #include <stdint.h>
    #include "simplelink.h"
    #include "sl_common.h"
    #include "driverlib/pin_map.h" //Mapping of peripherals to pins for all parts.
    #include "inc/hw_memmap.h" // Memory map definitions of the Tiva C Series device.
    #include "inc/tm4c123gh6pm.h" // Definitions for the interrupt and register assignments.
    #include "driverlib/sysctl.h" // Definitions and macros for System Control API of DriverLib.
    #include "driverlib/adc.h" // Definitions for ADC API of DriverLib.
    #include "inc/hw_types.h" // Definitions of common types and macros.
    #include "driverlib/gpio.h" // Definitions and macros for GPIO API of DriverLib.

    #include "driverlib/interrupt.h" // Defines and macros for NVIC Controller API of DriverLib.
    #include "driverlib/timer.h" // Defines and macros for Timer API of DriverLib.

    #define TIMER0_FREQ 2 // Freqency in Hz, heartbeat timer

    #define RED_LED GPIO_PIN_1
    #define BLUE_LED GPIO_PIN_2
    #define GREEN_LED GPIO_PIN_3

    void Timer0_ISR(void);

    void init_LEDs(void);

    void init_timer(void);



    _u8 cur_LED = BLUE_LED;

    void main(){

    init_LEDs();
    init_timer();

    SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); // 80 MHz

    sys_clock = 80000000; // Hard coded for 80MHz because of a bug in SysCtlClockGet().

    // Enable the processor to respond to interrupts.

    IntMasterEnable();

    // Start the timer by enabling operation of the timer module.

    TimerEnable(TIMER0_BASE, TIMER_A);

    }


    void init_LEDs(void)
    {
    // Enable and configure LED peripheral.
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Enable GPIO Port F.
    // Three onboard LEDs, R:PF1, B:PF2, G:PF3.
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
    }

    void init_timer(void)
    {
    // Enable and configure Timer0 peripheral.
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    // Configure as a 32-bit timer in periodic mode.
    TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
    // Initialize timer load register.
    TimerLoadSet(TIMER0_BASE, TIMER_A, sys_clock/TIMER0_FREQ -1);

    // Registers a function to be called when the interrupt occurs.
    IntRegister(INT_TIMER0A, Timer0_ISR);
    // The specified interrupt is enabled in the interrupt controller.
    IntEnable(INT_TIMER0A);
    // Enable the indicated timer interrupt source.
    TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    }

    void Timer0_ISR(void)
    {

    // Clear the timer interrupt.
    TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

    // Blink LED. Read the current state of GPIO pins and write back the opposite state.
    if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3)) {
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0);
    }
    else {
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, BLUE_LED);
    }
    }

  • Hello Michael

    TimerEnable API call to enable the timer is missing

    Regards
    Amit
  • Amit,

    Thank you for your response, I forgot to include these lines when I was coping code into the browser.  Is this the enable that you are referring to?

    IntMasterEnable();

    // Start the timer by enabling operation of the timer module.

    TimerEnable(TIMER0_BASE, TIMER_A);

    TimerEnable(TIMER1_BASE, TIMER_A);

    Edit:

    I have also tried flashing old code on to the TM4C123 and it flashed the onboard LEDs.  Which leads me to surmise that it is within the example code somewhere.  We have been pouring over the code and have not found how to get around it yet.  I will post up the example code which was used once I get to my USB drive with the code.

  • Hello Michael

    Yes, that is correct. But in the updated code I do not see the function init_timer() being called in the main()

    Regards
    Amit
  • Amit,

    I placed it above main when pasting it in to the browser. Thank you for pointing it out. I will fix that. How embarrassing.
  • Hello Michael,

    So is the timer working now?

    Regards
    Amit
  • Hi Amit,

    Might this humble, sometimes forum participant note that not many here, "Code, Analyze & Respond" like Amit.

    Thoughts of Turkey & friends/family likely "break" poster's TM4C focus...   (it's barely been 2 hours since poster last wrote...)

    Happy Thanksgiving, Amit.  

  • Amit,

    No the timer is still not working.  Here is some more of the example code we are using created by TI.  I am pouring over the datasheet but to no avail so far.  Thank you again for all of your help.  I am very interested to learn more and plan to expand the project into a senior project. 

    /*

    * board.c - tiva-c launchpad configuration

    *

    * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/

    *

    *

    * Redistribution and use in source and binary forms, with or without

    * modification, are permitted provided that the following conditions

    * are met:

    *

    * Redistributions of source code must retain the above copyright

    * notice, this list of conditions and the following disclaimer.

    *

    * Redistributions in binary form must reproduce the above copyright

    * notice, this list of conditions and the following disclaimer in the

    * documentation and/or other materials provided with the

    * distribution.

    *

    * Neither the name of Texas Instruments Incorporated nor the names of

    * its contributors may be used to endorse or promote products derived

    * from this software without specific prior written permission.

    *

    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS

    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT

    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR

    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT

    * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,

    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT

    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,

    * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY

    * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT

    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE

    * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    *

    */

    #include "simplelink.h"

    #include "inc/tm4c123gh6pm.h"

    #include "inc/hw_memmap.h"

    #include "inc/hw_ssi.h"

    #include "inc/hw_types.h"

    #include "driverlib/ssi.h"

    #include "driverlib/rom.h"

    #include "driverlib/gpio.h"

    #include "driverlib/sysctl.h"

    #include "driverlib/fpu.h"

    #include "driverlib/uart.h"

    #include "board.h"

     

    P_EVENT_HANDLER pIrqEventHandler = 0;

    _u8 IntIsMasked;

     

    void initClk()

    {

    /*The FPU should be enabled because some compilers will use floating-

    * point registers, even for non-floating-point code. If the FPU is not

    * enabled this will cause a fault. This also ensures that floating-

    * point operations could be added to this application and would work

    * correctly and use the hardware floating-point unit. Finally, lazy

    * stacking is enabled for interrupt handlers. This allows floating-

    * point instructions to be used within interrupt handlers, but at the

    * expense of extra stack usage. */

    FPUEnable();

    FPULazyStackingEnable();

    /*Initialize the device with 16 MHz clock.

    * 16 MHz Crystal on Board. SSI Freq - configure M4 Clock to be ~50 MHz */

    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN

    |SYSCTL_XTAL_16MHZ);

    }

    void stopWDT()

    {

    }

    int registerInterruptHandler(P_EVENT_HANDLER InterruptHdl , void* pValue)

    {

    pIrqEventHandler = InterruptHdl;

    return 0;

    }

    void CC3100_disable()

    {

    ROM_GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4, PIN_LOW);

    }

    void CC3100_enable()

    {

    ROM_GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4, PIN_HIGH);

    }

    void CC3100_InterruptEnable()

    {

    GPIOIntEnable(GPIO_PORTB_BASE,GPIO_PIN_2);

    #ifdef SL_IF_TYPE_UART

    ROM_UARTIntEnable(UART1_BASE, UART_INT_RX);

    #endif

    }

    void CC3100_InterruptDisable()

    {

    GPIOIntDisable(GPIO_PORTB_BASE,GPIO_PIN_2);

    #ifdef SL_IF_TYPE_UART

    ROM_UARTIntDisable(UART1_BASE, UART_INT_RX);

    #endif

    }

    void MaskIntHdlr()

    {

    IntIsMasked = TRUE;

    }

    void UnMaskIntHdlr()

    {

    IntIsMasked = FALSE;

    }

    void Delay(unsigned long interval)

    {

    ROM_SysCtlDelay( (ROM_SysCtlClockGet()/(3*1000))*interval );

    }

    void GPIOB_intHandler()

    {

    unsigned long intStatus;

    intStatus = GPIOIntStatus(GPIO_PORTB_BASE, 0);

    GPIOIntClear(GPIO_PORTB_BASE,intStatus);

    if(intStatus & GPIO_PIN_2)

    {

    #ifndef SL_IF_TYPE_UART

    if(pIrqEventHandler)

    {

    pIrqEventHandler(0);

    }

    #endif

    }

    }

    void UART1_intHandler()

    {

    unsigned long intStatus;

    intStatus =UARTIntStatus(UART1_BASE,0);

    UARTIntClear(UART1_BASE,intStatus);

    #ifdef SL_IF_TYPE_UART

    if((pIrqEventHandler != 0) && (IntIsMasked == FALSE))

    {

    pIrqEventHandler(0);

    }

    #endif

    }

  • Hello Michael,

    First lets look at the original code that you have before adding the new code structure. Can you please paste the last updated code that we can use to go about with the correct development of the code.

    Also note that the interrupt handler must be initialized in the startup file as well.

    Regards
    Amit