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/CC3200: CC3200 capture mode

Part Number: CC3200

Tool/software: Code Composer Studio

I want to create one timer interrupt of 1 sec as well as 1 Counter interrupt which overflows when match value is found.

I want both interrupt in single Function..


  • // Standard include
    #include <stdio.h>

    // Driverlib includes
    #include "hw_types.h"
    #include "interrupt.h"
    #include "hw_ints.h"
    #include "hw_apps_rcm.h"
    #include "hw_common_reg.h"
    #include "prcm.h"
    #include "gpio.h"
    #include "rom.h"
    #include "rom_map.h"
    #include "hw_memmap.h"
    #include "timer.h"
    #include "utils.h"
    #include "pin.h"

    // Common interface includes
    #include "timer_if.h"
    #include "gpio_if.h"
    #include "uart_if.h"
    #include "pinmux.h"


    //*****************************************************************************
    // MACRO DEFINITIONS
    //*****************************************************************************
    #define APPLICATION_VERSION "1.1.1"
    #define APP_NAME "MFM Square Pulse Measurement"
    #define FOREVER 1

    //*****************************************************************************
    // Global Variables for Vector Table
    //*****************************************************************************
    #if defined(ccs)
    extern void (* const g_pfnVectors[])(void);
    #endif
    #if defined(ewarm)
    extern uVectorEntry __vector_table;
    #endif

    //*****************************************************************************
    //
    // Globals used by the timer interrupt handler.
    //
    //*****************************************************************************
    static volatile unsigned long g_ulSysTickValue;
    static volatile unsigned long g_ulBase;
    static volatile unsigned long g_ulRefBase;
    static volatile unsigned long g_ulRefTimerInts = 0;
    static volatile unsigned long g_ulIntClearVector;
    unsigned long counter_overflows;
    static unsigned long total_counts;
    static unsigned long sec;
    unsigned long g_ulTimerInts;

    //*****************************************************************************
    //
    //! The interrupt handler for the first timer interrupt.
    //!
    //! \param None
    //!
    //! \return none
    //
    //*****************************************************************************
    void
    TimerBaseIntHandler(void)
    {
    //
    // Clear the timer interrupt.
    //
    Timer_IF_InterruptClear(g_ulBase);
    sec++;
    total_counts = counter_overflows*10000 + MAP_TimerValueGet(TIMERA2_BASE,TIMER_A);
    Report("Total Pulse count in %d Sec: %d \n\r",sec,total_counts);
    GPIO_IF_LedToggle(MCU_RED_LED_GPIO);//MCU_GREEN_LED_GPIO
    }
    //*****************************************************************************
    //
    //! Timer interrupt handler
    //
    //*****************************************************************************
    static void TimerIntHandler()
    {
    //
    // Clear the interrupt
    //
    MAP_TimerIntClear(TIMERA2_BASE,TIMER_CAPA_MATCH);
    counter_overflows++;
    TimerValueSet(TIMERA2_BASE, TIMER_A, 0x00);
    Report("In ISR: %d Value: 0x%x \n\r",counter_overflows, MAP_TimerValueGet(TIMERA2_BASE,TIMER_A));
    }
    //*****************************************************************************
    //
    //! Application startup display on UART
    //!
    //! \param none
    //!
    //! \return none
    //!
    //*****************************************************************************
    void
    DisplayBanner(char * AppName)
    {

    Report("\n\n\n\r");
    Report("\t\t *************************************************\n\r");
    Report("\t\t\t CC3200 %s Application \n\r", AppName);
    Report("\t\t *************************************************\n\r");
    Report("\n\n\n\r");
    }

    //*****************************************************************************
    //
    //! Board Initialization & Configuration
    //!
    //! \param None
    //!
    //! \return None
    //
    //*****************************************************************************
    static void
    BoardInit(void)
    {
    /* In case of TI-RTOS vector table is initialize by OS itself */
    #ifndef USE_TIRTOS
    //
    // Set vector table base
    //
    #if defined(ccs)
    MAP_IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
    #endif
    #if defined(ewarm)
    MAP_IntVTableBaseSet((unsigned long)&__vector_table);
    #endif
    #endif
    //
    // Enable Processor
    //
    MAP_IntMasterEnable();
    MAP_IntEnable(FAULT_SYSTICK);

    PRCMCC3200MCUInit();
    }

    //*****************************************************************************
    //
    //! main function demonstrates the use of the timers to generate
    //! periodic interrupts.
    //!
    //! \param None
    //!
    //! \return none
    //
    //*****************************************************************************
    int
    main(void)
    {
    //
    // Initialize board configurations
    BoardInit();
    //
    // Pinmux
    //
    PinMuxConfig();
    //
    // Configuring UART
    //
    InitTerm();
    //
    // Display Application Banner
    //
    DisplayBanner(APP_NAME);
    //
    // configure the LED RED and GREEN
    //
    GPIO_IF_LedConfigure(LED1);

    GPIO_IF_LedOff(MCU_RED_LED_GPIO);

    //
    // Base address for first timer
    //
    g_ulBase = TIMERA0_BASE;
    //
    // Configuring the timers
    //
    Timer_IF_Init(PRCM_TIMERA0, g_ulBase, TIMER_CFG_PERIODIC, TIMER_A, 0);
    //
    // Setup the interrupts for the timer timeouts.
    //
    Timer_IF_IntSetup(g_ulBase, TIMER_A, TimerBaseIntHandler);
    //
    // Turn on the timers feeding values in mSec
    //
    Timer_IF_Start(g_ulBase, TIMER_A, 1000);//1sec delay
    //
    // Loop forever while the timers run.
    //
    //
    // Enable pull down
    //
    MAP_PinConfigSet(PIN_15,PIN_TYPE_STD_PD,PIN_STRENGTH_6MA);


    //
    // Register timer interrupt hander
    //
    MAP_TimerIntRegister(TIMERA2_BASE,TIMER_A,TimerIntHandler);

    //
    // Configure the timer in edge count mode
    //
    MAP_TimerConfigure(TIMERA2_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT_UP));//TIMER_CFG_A_CAP_COUNT_UP :for up count,TIMER_CFG_A_CAP_COUNT:down count

    //
    // Set the detection edge
    //
    MAP_TimerControlEvent(TIMERA2_BASE,TIMER_A,TIMER_EVENT_POS_EDGE);//

    //
    // Set the reload value/* *******/
    //
    MAP_TimerMatchSet(TIMERA2_BASE,TIMER_A,10000);
    MAP_TimerLoadSet(TIMERA2_BASE,TIMER_A,11000);


    //
    // Enable capture event interrupt
    //
    MAP_TimerIntEnable(TIMERA2_BASE,TIMER_CAPA_MATCH);//For Edge :TIMER_CAPA_MATCH// for time: TIMER_CAPA_EVENT

    //
    // Enable Timer
    //
    MAP_TimerEnable(TIMERA2_BASE,TIMER_A);
    while(FOREVER)
    {
    }
    }

  • Kiran,

    Is your issue resolved? You marked your post with the code as Resolved - was that incorrectly marked? If it was incorrectly marked, please Reject it so the thread gets reopened and looked at.