Author Topic: using the GPT inputs  (Read 26735 times)

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: using the GPT inputs
« Reply #15 on: December 13, 2008, 08:23:58 PM »
Hi Neil

I am going to try the same to see whether I can reproduce the same behavior.
I'll get back.

Regards

Mark

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: using the GPT inputs
« Reply #16 on: December 13, 2008, 09:01:40 PM »
Hi Neil

I have made some tests.

1. I used my test set up and connected the blinking LED output to GPT0 input. This is 2.5Hz rather than 1Hz but this should be representative.
With a capture buffer length of 20 I got an interrupt after about 8s with the following capture times:

0x0008929e
0x001402a9
0x001f72b6
0x002ae2c2
0x003652cd
0x0041c2da
0x004d32e5
0x0058a2ef
0x006412fb
0x006f8307
0x007af313
0x0086631f
0x0091d32b
0x009d4337
0x00a8b341
0x00b4234d
0x00bf9359
0x00cb0365
0x00d67371
0x00e1e37d

There seems to be 400ms (delta 0xb700c / 1.875MHz) between each capture so perform as expected.

2. I checked again with no pull up defined (shouldn't make any difference as there is a port output driving the input). The results were identical (even every individual capture value was exactly repeated).

Therefore I didn't find any problems with this.

Question: What voltage do you have on the input? Is is possible that you are driving the input with a voltage greater than 3V3? Or that the voltage is not falling to 0V but to maybe 1V or so? Over-driving the input or not driving adequately to '0' could cause strange effects(?)

Regards

Mark


Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: using the GPT inputs
« Reply #17 on: December 14, 2008, 07:03:14 PM »
Hi mark,
  I found what the problem was. I was driving the GPT0 pin through a mosfet, with a pulldown on the drain going to the GPT0 pin, and disabled teh pullup resistor on the GPT0 setup. The signal looked perfect through the scope (and also stuck a logic analyser on it), with voltages correct. I removed the mosfet and drove the pin directly, and works perfect. I dont know what the cause can be, but will drive it through a transistor next time.

Thanks for all your help Mark,

Regards
Neil

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: using the GPT inputs
« Reply #18 on: March 26, 2009, 02:47:01 PM »
Hi Mark,
  I have the output of my RTC going to input capture channel 3 of the 52259. I have set the RTC to output a 1Hz pulse which goes to the pin and want to call my task from the interupt routine. I wish the interupt to be called on every high->low transaction of the pulse, and not interested in the time, just the transaction.

1. How do I set it up so it keeps interupting every high->low transaction without having to call the below within the interupt routine?
2. As I am not interested in the time side of it, what can I place in the 'gptimer_setup.capture_list' ?Saves using a dummy variable?


void fnConfigure_GPT(void)
{
    GPTIMER_SETUP gptimer_setup;                                         // interrupt configuration parameters
    gptimer_setup.int_type = GPT_TIMER_INTERRUPT;
    gptimer_setup.int_handler = gptimer_int;
    gptimer_setup.channel = 3;                                           // general purpose timer channel 1
    gptimer_setup.int_priority = GPTIMER0_INTERRUPT_PRIORITY;            // define interrupt priority
    gptimer_setup.mode = GPT_CAPTURE_FALLING_EDGE;
    gptimer_setup.usCaptureCount = 1;                         // request this many capture values to be recorded before calling our interrupt
    gptimer_setup.capture_list = ulCaptureList;                          // the capture list for saving to
    fnConfigureInterrupt((void *)&gptimer_setup);                        // enter interrupt for DMA timer test
 
}


Best Regards
Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: using the GPT inputs
« Reply #19 on: March 26, 2009, 05:00:43 PM »
Hi Neil

You can set a dummy variable to accept the single capture value. You can also also disable GPT_EXTENDED_COUNTER since you are not interested in the counter being extended to 32 bit using the overflow interrupt.

The timer is disabled when the capture sequence has completed (as long as no other channels are still active) and needs to be re-initialised between interrupts. This can be performed by calling the fnConfigureInterrupt() again. gptimer_setup can also be set up as a const structure so that it is a bit more efficient, but this is of course still not the most efficient method of using a GTP edge pin as general purpose edge triggered interrupt.

I have quickly tested the following extension.

1) In app_hw_m5223x.h I added a new define

    #define GPT_SIMPLE_INTERRUPT                                         // allow use a simple edge triggered interrupt

2) In m5223x.c I slightly extended the interrupt handler with the following lines:

static void gp_timer_int(int iChannel, unsigned short usChannelCounter)
{
    if (gpt[iChannel].usCaptureTrigger) {                                // if we are handling captures
 ....
    }
#ifdef GPT_SIMPLE_INTERRUPT
    else {
    #ifdef _WINDOWS
        if (GPTSCR1 & TFFCA) {                                           // if the fast clearing flag is set
            GPTFLG1 &=  ~(0x01 << iChannel);                             // clear the interrupt due to previous read
        }
    #endif
        iInterruptLevel = 1;
        GPT_count_interrupt_callback[iChannel]();                        // call the user handler
        iInterruptLevel = 0;
    }
#endif
}



This now allows a zero count value to be entered and the capture input can be used as a continuous edge triggered interrupt.

It needs to be set up just once with the standard configuration, using settings:
gptimer_setup.usCaptureCount = 0;
gptimer_setup.capture_list = 0; // could also be left un-initialised since not used


Tell me if this is successful for you and then I will commit it to the master project.

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: using the GPT inputs
« Reply #20 on: March 26, 2009, 06:00:10 PM »
Hi Mark,
  That works perfect, cheers.

Does this still allow any other channels to operate as input capture?

Regards
Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: using the GPT inputs
« Reply #21 on: March 26, 2009, 06:05:49 PM »
Hi Neil

Yes, all channels are independent.

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: using the GPT inputs
« Reply #22 on: April 07, 2009, 03:21:52 PM »
Hi Mark,
  I am using one of the channels to interupt on both edges, but I would like to know at any point the logic level of the input. How do I do this while the input is in GPT mode?

Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: using the GPT inputs
« Reply #23 on: April 07, 2009, 04:17:05 PM »
Hi Neil

I believe that you can read the pin state using the GPTPORTregister.

Regards

Mark