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.

Input Edge count mode with EK-TM4C1294XL

Other Parts Discussed in Thread: TM4C1294NCPDT, EK-TM4C1294XL

Hi, 

I'm trying to use the input edge count mode timer with a TM4C1294NCPDT on a launchpad kit  (EK-TM4C1294XL).

I'm using the PM2 as the input for the clock signal and PK2 as a input for edge interrupt.

I just want to count 1 full clock cycle, not both edges.

The configuration code is below

// CCP on PM2
GPIOPinTypeGPIOInput(GPIO_PORTM_BASE, GPIO_PIN_2);
GPIOPinConfigure(GPIO_PM2_T3CCP0);
GPIOPinTypeTimer(GPIO_PORTM_BASE,GPIO_PIN_2);
// T3CCP
TimerDisable(TIMER3_BASE,TIMER_A);
TimerConfigure(TIMER3_BASE,TIMER_CFG_A_PERIODIC_UP);
TimerControlEvent(TIMER3_BASE,TIMER_A,TIMER_EVENT_POS_EDGE);
TimerLoadSet(TIMER3_BASE, TIMER_A, 0);
TimerMatchSet(TIMER3_BASE, TIMER_A, 24);
IntRegister(INT_TIMER3A,pinCCP_interrupt);
TimerEnable(TIMER3_BASE,TIMER_A);

My pinCCP_interrupt

void pinCCP_interrupt(void){

	GPIOIntClear(GPIO_PORTM_BASE, GPIO_PIN_2);
	TimerDisable(TIMER3_BASE,TIMER_A);

	GPIOIntEnable(GPIO_PORTK_BASE, GPIO_PIN_2);
        cont_clock=0;
}

And the edge interrupt, working fine:

void clk_lvds(void)
{	
	GPIOIntClear(GPIO_PORTK_BASE, GPIO_PIN_2);
	cont_clock++;

	if(cont4<FRAME_SIZE)		
	{
		if(cont_clock<13)
		{
			//..some task
		}
                else		
		{
			TimerEnable(TIMER3_BASE,TIMER_A);
                        GPIOIntDisable(GPIO_PORTK_BASE,GPIO_PIN2);
		}
		if(cont_clock==36)
			cont_clock=0;
	}
}

After a number of 24 clocks, i want to stop counting and activate an interrupt on 2 other pins, which afterwards will activate the counter again, but pinCCP_interrupt is never called.

Also, i also have a question: how fast an interrupt can be enabled and disabled? I have a clock signal with 1Mhz frequency, but every 12 clocks i'm using an edge interrupt for a specific task, working and tested fine, and the other 24 clocks i just want to skip. My actual code just counts every time i enter the edge interrupt and exits if the clock is between 13 and 36, but i want to optimize using the input edge counter. Is this possible?

Also, is there any example using such timer mode? I already checked those links but i couldnt figure out what's wrong.

https://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/210016

e2e.ti.com/.../1082359

  • Hello Daniolip

    1. How are you disabling the counting?
    2. What are the other 2 pins?
  • Amit Ashara said:
    Hello Daniolip

    1. How are you disabling the counting?
    2. What are the other 2 pins?

    1- I'm turning off the timer3 at the count interrupt

    TimerDisable(TIMER3_BASE,TIMER_A);

    2- PK2 and PG1 i think, i don't have the code right now. In fact,i just need to turn off PK2 edge interrupt, which also works, but since the count interrupt never occurs, the PK2 interrupt is never turned on again.

  • Hello Daniolip

    In the interrupt handler why is the GPIOIntClear(GPIO_PORTM_BASE, GPIO_PIN_2); being called which is clearing an interrupt status bit on PM2 which is the Timer input pin?
  • Hi daniolip,

    Notice a few things about TM3. First TM3 being set for periodic mode and you claim is thus set CCP mode, that don't seem possible does it ? and ...

    Note that when executing an up-count, the value of the GPTMTnPR and GPTMTnILR must be greater than the value of GPTMTnPMR and GPTMTnMATCHR.
  • Amit Ashara said:
    Hello Daniolip


    In the interrupt handler why is the GPIOIntClear(GPIO_PORTM_BASE, GPIO_PIN_2); being called which is clearing an interrupt status bit on PM2 which is the Timer input pin?

    PM2 is the pin i want to use with the Input Edge Count mode.

    PM2 ->"Input edge count"

    PK2 -> Rising edge interrupt

    Both PM2 and PK2 receive the same clock signal, but while PK2 is receiving the first 12 clock cycles with an Rising Edge interrupt, PM2 and the "Input edge count" should be off.

    After the 12 clock signals, PK2 and its Rising Edge interrupt need to be disabled and PM2 and the "Input edge count" should be enabled and count 24 clocks. After the 24 clocks, the cycle completes and PM2/Input edge count is disabled while PK2 and its Rising Edge Interrupt are enabled again.

    BP101 said:
    Hi daniolip,

    Notice a few things about TM3. First TM3 being set for periodic mode and you claim is thus set CCP mode, that don't seem possible does it ? and ...

    Note that when executing an up-count, the value of the GPTMTnPR and GPTMTnILR must be greater than the value of GPTMTnPMR and GPTMTnMATCHR.

    So, how should i config the TIMER3 to work in countmode? There are very few examples on the web about that so i'm really confused.

    So instead of setting MATCH to 24, i should set LOAD to 24?

  • There are several examples of how to configure CCP input edge count (search) this forum top of web page. Be sure to down load TM4C datasheet and read timers section to gain full understanding of what you are trying to do actually works as you might only be guessing now. It takes a few reads to grasp it all and maybe a few more reads days later but it will all come together, just keep positive and try not to get frustrated! :-)

  • Hello Daniolip

    I am still not quire sure why such a complicated method. Configure the timer for TIMER_CFG_A_CAP_TIME mode and time stamp the incoming edges.
  • BP101 said:

    There are several examples of how to configure CCP input edge count (search) this forum top of web page. Be sure to down load TM4C datasheet and read timers section to gain full understanding of what you are trying to do actually works as you might only be guessing now. It takes a few reads to grasp it all and maybe a few more reads days later but it will all come together, just keep positive and try not to get frustrated! :-)

    Thanks. I get frustrated really easily, even more when the project is getting delayed because of my difficulties to understand this. Perhaps the weekend will give me some breathing room.

    Amit Ashara said:
    Hello Daniolip

    I am still not quire sure why such a complicated method. Configure the timer for TIMER_CFG_A_CAP_TIME mode and time stamp the incoming edges.

    It's not clear on the OP, but basically i have an CPU sending data using 46k clock cycles per frame coming on a shared BUS for 3 ARM processors, 1/3 of the clocks are for each one of the ARM processors, the other 2/3 should just be ignored. But the BUS speed is limited to the ARM processors reading speed via rising edge interrupts PLUS the main task on the main.

    Each rising edge interrupt called takes about 200-400ns to be processed by the ARM according to my measures. If i can ignore two thirds of the clocks, i can allocate more time to other tasks and send more frames per second to all my ARM processors.

    If processing time wasn't a issue, i wouldn't even bother to use the timer since i can just ignore the clocks inside my rising edge interrupt.

  • Hello daniolip,

    I would then suggest using the Capture Time mode. That would allow the CPU to be offloaded and then it can make the decision on which edges to record and which to ignore.