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.

32/64 TImer can't enter the interrupt of POS_EDGE

#TM-4C123GH6PM

I use the WT0CCP0 to detect the rising edge of PC4, however, Though there is the rising edge, the processor can't enter the interrupt

when I change it to T2CCP1, it works.

WHY the 32/64 timer can't enter the interrupt?  Is there any solution ? 

  • Hi,

    If you want a simple rising edge interrupt you can just use a GPIO interrupt

    About why the interrupt on the wide timer does not work i am not a medium, or else i would win the lottery. Please provide the code you use to configure the wide timer and the startup.c (in case you configure the handler there)

  • Thank you .I didn't know about the fantastic GPIO interrupt before. It's really useful

     

    And the code about the interrupt above is

    ///////////////////////////////////////////////////////

    SysCtlPeripher

    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
    SYSCTL_XTAL_16MHZ); 


    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    alEnable(SYSCTL_PERIPH_WTIMER0); 
    GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_4);
    GPIOPinConfigure(GPIO_PC4_WT0CCP0); 
    GPIOPinTypeTimer(GPIO_PORTC_BASE, GPIO_PIN_4);
    GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
    TimerConfigure(WTIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME); 
    TimerControlEvent(WTIMER0_BASE, TIMER_A, TIMER_EVENT_POS_EDGE); 
    TimerLoadSet(WTIMER0_BASE, TIMER_A, 0xffff); 
    TimerIntRegister(WTIMER0_BASE, TIMER_A, WTimer0AIntHandler); 
    IntPrioritySet(INT_WTIMER0A, 0<<5);
    TimerIntEnable(WTIMER0_BASE, TIMER_CAPA_EVENT); 
    IntEnable(INT_WTIMER0A); 
    TimerEnable(WTIMER0_BASE, TIMER_A);

     

    void WTimer0AIntHandler(void)
    {
    TimerIntClear(WTIMER0_BASE, TimerIntStatus(WTIMER0_BASE, TIMER_CAPA_EVENT)); 
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0xFF);
    BackForth(0);
    SysCtlDelay(SysCtlClockGet() / 6);
    if(distance(HEAD, PitPos[GOTOPIT_INDEX]) <25);
    GOTOPIT_INDEX = GOTOPIT_INDEX == 3 ? 0 : GOTOPIT_INDEX + 1;
    }

    /////////////////////////////////

    In the startup_css.c

    ///////////

    extern void WTimer0AIntHandler(void);

    WTimer0AIntHandler,                      // Wide Timer 0 subtimer A

  • Check this out for the digital interrupt: https://sites.google.com/site/luiselectronicprojects/tutorials/tiva-tutorials/tiva-gpio/digital-input-with-interrupt

    As for the code i'll have to see it later, as Fourier and his friends are going to make my head jelly for the next hours 

  • Hi,

    Depending on your configuration, odd or even pins may be used for capture. See the Timer chapter in user manual, there is a description of each timer and each active (possible) pin to use.

    @Luis,

    Using a GPIO interrupt is not working always - and this is because the interrupt system of Cortex micros. If there are other higher interrupt priorities, these can disturb such implementation, either by latest arrival mechanism or by nesting. The effect is the timer is either triggered, either stopped much later, causing decrease or increase of the measured interval, meaning inconsistent results.

    Petrei

  • however, My code never enter the interrupt instead of sometime

    By the way, can you tell me that how can i know which pin that a GPIO interrupt locate in

    such as that i configure 1,2,3Pin of Int_GPIOC,when i get into the interrput function, how can i know which pin causes the interrupt?

  • Hi,

    Actually you have mixed parts of both solutions - it is not going to work as such - suggest to remain consistent with your first request and start by searching this forum, there are some very good examples posted. Please try that.

    One word of caution: Port C pins 0..3 are used for JTAG. Do not try to use them otherwise, at least at this stage.

    Petrei

  • Petrei said:

    @Luis,

    Using a GPIO interrupt is not working always - and this is because the interrupt system of Cortex micros. If there are other higher interrupt priorities, these can disturb such implementation, either by latest arrival mechanism or by nesting. The effect is the timer is either triggered, either stopped much later, causing decrease or increase of the measured interval, meaning inconsistent results.

    Let me see if i understood. You are referring to the priority levels of the GPIO interrupts, which is much lower than the timer interrupts?

    Of course the type of interrupt used depends on how precise you need you application.

  • Hello Petrei,

    I agree with your assessment on mixing of solution.

    Hello ,

    The forum had a code post for the particular mode you mention. And i happen to had the code. May be this will be helpful (not tested it for quite some time now)

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/tm4c123gh6pm.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "inc/hw_timer.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/gpio.h"
    #include "driverlib/timer.h"
    #include "driverlib/pin_map.h"
    
    uint32_t period_value;
    
    int main(void)
    {
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
        SysCtlDelay(3);
    
        GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
        SysCtlDelay(3);
    
        GPIOPinTypeTimer(GPIO_PORTC_BASE, GPIO_PIN_4);
        GPIOPinConfigure(GPIO_PC4_WT0CCP0);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER0);
        SysCtlDelay(3);
    
        TimerConfigure(WTIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME_UP);
        TimerControlEvent(WTIMER0_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
        TimerIntEnable(WTIMER0_BASE, TIMER_CAPA_EVENT);
        TimerIntClear(WTIMER0_BASE, TIMER_CAPA_EVENT);
        IntEnable(INT_WTIMER0A);
        IntMasterEnable();
        TimerEnable(WTIMER0_BASE, TIMER_A);
        while(1)
        {
        }
    }
    
    void WTimer0IntHandler(void)
    {
        TimerIntClear(WTIMER0_BASE, TIMER_CAPA_EVENT);
        period_value = TimerValueGet(WTIMER0_BASE, TIMER_A);
        HWREG(WTIMER0_BASE+TIMER_O_TAV) = 0x0;
    }
    

    Regards

    Amit

  • Thank you very much, It is really useful 

  • hello Amit Ashara,

    there is some codes about  HWREG(WTIMER0_BASE+TIMER_O_TAV) = 0x0;

    Is there any special thing about the use of HWREG?

    In another part of my code, I use  HWREG(I2C1_BASE + I2C_O_MCR) |= 0x01;

    However the CCS causes error,

    "

    #138 expression must be a modifiable lvalue main.c /SENSORtest2 line 685 C/C++ Problem

    "

    and warning

    "

    function "HWREG" declared implicitly

    "

    But I have included the Header files  and needed define

    #ifndef __HW_TYPES_H__
    #define __HW_TYPES_H__ //HWREG

    #include<stdint.h>
    #include<stdbool.h>
    #include"stdio.h"
    #include"stdlib.h"
    #include"math.h"
    #include"inc/hw_memmap.h"
    #include"inc/hw_types.h"
    #include"inc/hw_ints.h"
    #include"inc/hw_i2c.h"
    #include"driverlib/gpio.h"
    #include"driverlib/pin_map.h"
    #include"driverlib/pwm.h"
    #include"driverlib/sysctl.h"
    #include"driverlib/uart.h"
    #include"driverlib/timer.h"
    #include"driverlib/interrupt.h"
    #include"driverlib/i2c.h"

    Can you tell me where the problem is ? How to correct it?

  • Hello user4178447

    HWREG is a macro to access a memory location (can be a peripheral register) and is defined in hw_types.h

    Regarding the error, can you check the line of code mentioned in the error (or paste a snapshot of the same)

    Also remove

    #ifndef __HW_TYPES_H__
    #define __HW_TYPES_H__ //HWREG

    and change

    #include"inc/hw_memmap.h"
    #include"inc/hw_types.h"

    to

    #include"inc/hw_types.h"
    #include"inc/hw_memmap.h"

    Regards

    Amit

  •  Just at the point.

    When I exchange the position of two header files, error disappeared.

    Thank you