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.

REG- Capture interrupt in TM4C123

Hi

     I am using Tm4C123 launch pad, now i want to use Capture interrupt for calculate three different motor speed(RPM), i done interface circuit for this and connected to three different input channel. 

Please anybody help to do software for this, Example code is better to clarity.

Yuvaraj

  • Hello Yuvaraj,

    What is the trouble that you are facing? The question you have asked is too broad to answer. Please list a specific problem when developing the application or system, so that we can help you better.

    Thanks,
    Sai
  • Hello Sai,

    I am connected external sensor input to PB0 pin, My problem is the interrupt occurred whenever sensor input is low, but i can't read exact timer value for speed calculation. I am paste my code below

    Regards

    Yuvaraj



    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/fpu.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/timer.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/rom_map.h"
    #include "grlib/grlib.h"
    #include "utils/ustdlib.h"

    //*****************************************************************************

    uint32_t g_ui32Flags;
    volatile uint32_t g_ui32IntCount;
    tContext g_sContext;

    #define PRINT_BUFF_SIZE 8
    char g_pcPrintBuff[PRINT_BUFF_SIZE];

    unsigned long temp_long, temp_long1;
    unsigned char temp, temp1;

    void Timer2IntHandler();

    void ProcessInterrupt(void)
    {
        g_ui32IntCount++;

        if(temp == 0)
        {
            temp = 12;
            temp_long = TimerValueGet(TIMER2_BASE, TIMER_A);
        }
        else
        {
            temp_long1 = TimerValueGet(TIMER2_BASE, TIMER_A);
            temp = 0;
            temp_long1 = 0;
            temp_long = 0;
        }

    }

    void MainLoopRun(void)
    {
        uint32_t ui32Count, ui32LastCount;
        ui32LastCount = 10;
        while(1)
        {
            if(ui32Count != ui32LastCount)
            {
                ui32LastCount = ui32Count;
            }
            if(HWREGBITW(&g_ui32Flags, 0))
            {
                HWREGBITW(&g_ui32Flags, 0) = 0;
            }
        }
    }

    void Timer2IntHandler(void)
    {
        TimerIntClear(TIMER2_BASE, TIMER_CAPA_MATCH);

        ProcessInterrupt();
        TimerEnable(TIMER2_BASE, TIMER_A);
    }

    int main(void)
    {
        SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

        SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

        GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_0);
        GPIOPinConfigure(GPIO_PB0_T2CCP0);

        MAP_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
        IntMasterEnable();

        TimerConfigure(TIMER2_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT));
        TimerControlEvent(TIMER2_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
        TimerLoadSet(TIMER2_BASE, TIMER_A, 2500);
        TimerMatchSet(TIMER2_BASE, TIMER_A, 0);

        IntEnable(INT_TIMER2A);
        TimerIntEnable(TIMER2_BASE, TIMER_CAPA_MATCH);

        TimerEnable(TIMER2_BASE, TIMER_A);

        MainLoopRun();
    }