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 Capture TM4C123



I'm trying to do a simple test program to count positive edges using edge capture mode on the TM4C123 LaunchPad. The code is based on edge_count.c in the TivaWare examples - changed to be compatible with TM4C123 instead of LM4F232.

When I read the timer value, it never changes. I've tried various frequency input signals on the PB4 pin. 

Thanks,

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

#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/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"

//*****************************************************************************
//! UART0, connected to the Virtual Serial Port and running at 115,200, 8-N-1,
//! is used to display messages from this application.
//
//*****************************************************************************

//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif

//*****************************************************************************
//
// Configure the UART and its pins. This must be called before UARTprintf().
//
//*****************************************************************************
void
ConfigureUART(void)
{
//
// Enable the GPIO Peripheral used by the UART.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

//
// Enable UART0
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

//
// Configure GPIO Pins for UART mode.
//
ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

//
// Use the internal 16MHz oscillator as the UART clock source.
//
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);

//
// Initialize the UART for console I/O.
//
UARTStdioConfig(0, 115200, 16000000);
}

//*****************************************************************************
//
//*****************************************************************************
int
main(void)
{
uint32_t ui32Count, ui32LastCount;

//
// Enable lazy stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
ROM_FPULazyStackingEnable();

//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);

//
// Initialize the UART and write status.
//
ConfigureUART();

UARTprintf("\033[2JEdge count example\n");

//
// Enable the GPIO port that is used for the on-board LED.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

//
// Enable the GPIO pins for the LED (PF2 & PF1).
//
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_1);


//
// Enable the peripherals used by this example.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);


GPIOPinConfigure(GPIO_PB4_T1CCP0);
ROM_GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_4);

// GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_4,
// GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

ROM_TimerConfigure(TIMER1_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT_UP));

ROM_TimerControlEvent(TIMER1_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, 0);
ROM_TimerMatchSet(TIMER1_BASE, TIMER_A, 0xFFFF);
ROM_TimerPrescaleSet(TIMER1_BASE, TIMER_A, 0);
ROM_TimerPrescaleMatchSet(TIMER1_BASE, TIMER_A, 0xFF);

ROM_TimerEnable(TIMER1_BASE, TIMER_A);

ui32LastCount = 0;

while(1)
{
// Get the current timer count.

ui32Count = TimerValueGet(TIMER1_BASE, TIMER_A);

//
// Has it changed?
//
if(ui32Count != ui32LastCount)
{
UARTprintf("%x ", ui32Count);
ui32LastCount = ui32Count;
SysCtlDelay(SysCtlClockGet()/30);
}
}
}

  • Hello Lance,

    What is the frequency of the input signal being used on PB4. Note that the input signal must not exceed System Clock divided by 4. Other than that I can't see why the code should not work.
  • Hello Amit,

    I have tried with square waves with frequencies of 10 Hz up to 11 kHz. Several of my students have tried similar edge count programs with the TM4C123 and none of us have been able to get it to work. I've looked at examples and it seems like this code should work, but  TimerValueGet always returns the originally loaded value - the count does not change. Do you know of any working example for the TM4C123 for edge count mode?

    Thanks,

    Lance

  • Lance Halsted said:
    // Has it changed?
    //ui32Count = TimerValueGet(TIMER1_BASE, TIMER_A);

    //
    if(ui32Count != ui32LastCount)
    {
    UARTprintf("%x ", ui32Count);
    ui32LastCount = ui32Count;
    SysCtlDelay(SysCtlClockGet()/30); }

    Might your test be too severe to enable the count to register?   Note that your delay (only) appears when the "new/old" counts differ - thus the TimerValueGet() function is called @ machine-gun rates.

    I'm also unsure if "PB4" may not be "blessed" w/delightful 0Ω "Plague-Istor" - tieing it (directly) to another MCU pin - which may kill your signal input...   And - always wise to probe the actual MCU pin - to insure that your input signal HAS reached its desired destination...  And surely the sig. generator and MCU ground are made common...

  • Thanks for the suggestions!!
    I checked all these out and still no luck.
    I moved the delay out of the if {} block so that it delays after each call of TimerValueGet(). No change.
    I checked the schematic and PB4 looks ok. I decided to try another pin, just in case, so I changed the
    program to use TIMER0 / T0CCP0 / PF0. Still doesn't work.
    I probed the actual LaunchPad pin and it gets the square wave and yes, the function generator
    and the MCU have a common ground.
    I don't know what to suspect. Maybe a bug in a TivaWare API or perhaps a hardware issue with the
    MCU itself. Both seem unlikely. I'm hoping there's a working example somewhere to
    show that the mode works.
  • Wow - I have succeeded w/LX4F231 device under StellarisWare. If time allows - I'll search for our code - and migrate it to our 123 LPad.

    Note that in our testing we employed a "spare" MCU GPIO (set as pp output) to feed the Timer input pin. In this manner we could control the number of - and frequency of Timer Input Signals. It will be nightfall (CST) before I can locate & set everything up - then report.

    I recall that we are strong believers in "KISS" (simple STUDENT!) and made NO USE of the prescaler - which in some modes operates in a "counter intuitive" (i.e. confounding) manner. Might you kill that - and try again?
  • Hello Lance,

    Can you check the same code without using the value of 0xFFFF in the load count?
  • Hello Amit, cb1:

    I tried without using the value of 0xFFFF in the match register. It was 0 in the load count and 0xFFFF in the match register. Anyway, I tried all sorts of combinations of load counts, match register, not setting each, etc. Nothing seems to work.

    I also tried it without the prescale load and match set. I had done it this way originally to follow the edge_count.c example for the LM4F232. It also doesn't help.

    Thanks.
  • Hello Lance,

    I made a small change to your program

    ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, 0);
    ROM_TimerMatchSet(TIMER1_BASE, TIMER_A, 0xFFFF);
    ROM_TimerPrescaleSet(TIMER1_BASE, TIMER_A, 1);
    ROM_TimerPrescaleMatchSet(TIMER1_BASE, TIMER_A, 0xFF);

    and it is counting as expected. There is a statement in the datasheet for Capture Count mode regarding UP count, that I am analyzing for the confirmation of the resolution or a possible issue in the device.
  • Hello Amit,

    Yes, that works! Now I get the following output

    Edge count example
    8ae 115c 1a0a 22b9 2b67 3415 3cc3 4572 4e20 56ce 5f7d 682b 70d9 7988 8236 8ae4 9393 9c41 a4ef ad9e b64c befa c7a8 d057 d905 e1b3 ea62 f310 fbbe 10000

    It looks like the counting stops once the match occurs. I thought in Up counting mode, it would continue. Anyway, this is very useful. We want to use it to read encoder counts periodically using a periodic timer interrupt. We will reset the load register at that point and have it start again.

    Thanks very much to both you and cb1!!! It's unclear to me why the change of prescale load value from 0 to 1 makes it work, but thanks for figuring that out!!

    Best,
    Lance
  • Hello Lance,

    Glad it got you going. What concerns me is that (a) the count up mode stops unlike the datasheet mentioning that it would continue counting and (b) the load of the pre-scale value does not match the description of the mode at all.

    Both of them need to be investigated.
  • As a guess - w/prescale set to 0 - it "rolls over" to 255 (if 8 bits) or 65K (if 16) and thus NO Count activity is noted till the pre-scaler "rolls over"!   (maybe...)

  • Hello cb1

    I believe so. But with a constant toggle as mentioned by the OP, it should have rolled over at some point.
  • Hello Amit,
    Actually, I'm still having issues with this mode. Now that I can get it to start counting, I cannot get it to re-start before it reaches the Match Value.

    I changed the loop as follows:
    while(1)
    {
    // Get the current timer count.

    ui32Count = TimerValueGet(TIMER1_BASE, TIMER_A);

    //
    // Has it changed?
    //
    if(ui32Count != ui32LastCount)
    {
    UARTprintf("%x ", ui32Count);
    ui32LastCount = ui32Count;

    if (ui32Count > 0xc000) {
    ROM_TimerDisable(TIMER1_BASE, TIMER_A);
    UARTprintf("\n");
    ROM_TimerConfigure(TIMER1_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT_UP));
    ROM_TimerControlEvent(TIMER1_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);

    TimerUpdateMode(TIMER1_BASE, TIMER_A, TIMER_UP_LOAD_IMMEDIATE);
    ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, 0x0);
    ROM_TimerPrescaleSet(TIMER1_BASE, TIMER_A, 1);
    ROM_TimerEnable(TIMER1_BASE, TIMER_A);
    }
    }
    SysCtlDelay(SysCtlClockGet()/30);
    }

    Basically, when the count exceeds 0xc000 as it counts toward 0xffff, I try to disable the timer and make it start over from 0. Here is what happens:

    Edge count example
    8ae 115c 1a0a 22b9 2b67 3415 3cc4 4572 4e20 56cf 5f7d 682b 70d9 7988 8236 8ae4 9393 9c41 a4ef ad9e b64c befa c7a9
    d057
    d905
    e1b4
    ea62
    f311
    fbbf
    10000

    I can't get it to start over from 0!! I tried disabling the timer, reconfiguring it, reenabling it, etc. and it just continues counting! It's very stubborn! I guess I'm going to have to have it interrupt on a match, clear the interrupt bit and then reenable the counter. It seems like I should be able to re-start it before it reaches the match value, but nothing I've tried works.

    Thanks,
    Lance
  • Hello Lance

    The right approach would be to use the Down count with load value of 0xC000. When it counts to 0, it will generate an interrupt and then you can re-enable it by calling TimerEnable API.
  • Hello Amit, cb1:

    I made some progress and can now count edges continually in Up mode without an interrupt handler. My configuration code is:

    ROM_TimerConfigure(TIMER1_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT_UP));

    ROM_TimerControlEvent(TIMER1_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
    ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, 0xFFFF);
    ROM_TimerMatchSet(TIMER1_BASE, TIMER_A, 0xFFFE);
    ROM_TimerPrescaleSet(TIMER1_BASE, TIMER_A, 0xFF);
    ROM_TimerPrescaleMatchSet(TIMER1_BASE, TIMER_A, 0x00);
    ROM_TimerIntClear(TIMER1_BASE, TIMER_CAPA_MATCH);

    ROM_TimerEnable(TIMER1_BASE, TIMER_A);

    ui32LastCount = 0;

    while(1)
    {
    // Get the current timer count.

    ui32Count = TimerValueGet(TIMER1_BASE, TIMER_A);

    //
    // Has it changed?
    //
    if(ui32Count != ui32LastCount)
    {
    UARTprintf("%x ", ui32Count);
    ui32LastCount = ui32Count;
    }
    SysCtlDelay(SysCtlClockGet()/30);
    }

    I use TimerLoadSet() and TimerPrescaleSet() to set the Load Reg and the Prescale Reg to their max values to get them out of the way. These registers need to be greater than the MatchRegister and the PrescaleMatchRegister. The Counter starts counting from 0x0000, not the Load Register Value. (This is in the Data Sheet, but it is non-intuitive.) Anyway, now the program counts continually from 0x0000 to 0xfffe and then wraps around and continues:

    Edge count example
    7d0 fa0 1770 1f40 2711 2ee1 36b1 3e81 4652 4e22 55f2 5dc2 6593 6d63 7533 7d04 84d4 8ca4 9474 9c45 a415 abe5 b3b5 bb86 c356 cb26 d2f7 dac7 e297 ea67 f238 fa08 1d9 9aa 117a 194a 211a 28eb 30bb 388b 405b 482c 4ffc 57cc 5f9c 676d 6f3d 770d 7ede 86ae 8e7e 964e 9e1f a5ef adbf b590 bd60 c530 cd00 d4d1 dca1 e471 ec42 f412 fbe2 3b3 b84 1354 1b24 22f4 2ac5 3295 3a65 4235 4a06 51d6 59a6 6176 6947 7117 78e7 80b8 8888 9058 9828 etc.

    If I load the PrescaleMatchRegister with 0xFE instead of 0x00, then I get almost a full 24-bit count before it rolls over.

    What I still don't know is how to restart the count value from 0 at arbitrary times. Obviously, the Load Register is not going to work. I tried disabling the timer, reconfiguring it and re-enabling it, but it still starts from the old value. There might be a way to directly clear the counter value. It doesn't seem like TivaWare has an API that can do it.

    Thanks,
    Lance
  • Hello Lance,

    As suggested earlier, use the down count method for a clean restart, rather than polling the GPTMTAR register.
  • Hi Amit,

    I found a way to reset the count value:

    if(ui32Count != ui32LastCount)
    {
    UARTprintf("%x ", ui32Count);
    ROM_TimerDisable(TIMER1_BASE, TIMER_A);
    HWREG(0x40031050) = 0; // clear GPTM Timer A Value
    ROM_TimerEnable(TIMER1_BASE, TIMER_A);
    }

    This gives:
    Edge count example
    457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 457 457 458 etc.

    I get the same count each time because I'm measuring a constant delay each time - SysCtlDelay(SysCtlClockGet()/30). Basically, what I was looking for was a way to start the timer from 0 for each interval I want to measure. Of course, using UP counting and doing a subtraction each time also works.

    I don't want to use count down because I want to restart at specific time intervals, not after a specific number of counts. We're measuring pulses from a motor encoder so the number of pulses will vary with the motor speed. Thus, I want to reset the count at defined intervals, not after a defined number of counts.

    Thanks,
    Lance
  • Actually, it works better without disabling and re-enabling the counter.

    if(ui32Count != ui32LastCount)
    {
    UARTprintf("%x ", ui32Count);
    HWREG(0x40031050) = 0; // clear GPTM Timer A Value
    }

    Edge count example
    7d0 7d1 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d1 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d1 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d1 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d1 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0 7d0

    This value (0x7d0) agrees with the previous loop value using UP counting. Apparently, disabling and re-enabling the timer is slow, causing counts to be missed (0x457 counts instead of 0x7d0).
  • It's surprising to me that (so many) counts are lost via enable/disable - especially at your (relatively) low input test frequencies.

    The detail & experimental effort you've expended are "First Class" - memorialized & applauded here! Sure to be a nice reference post for (others). If they can blunder into this thread...

    I must note that your use of, "SysCtlDelay(SysCtlClockGet()/30)" may not be as consistent nor as stable as you desire. Amit's written often here of the multiple factors which may reduce that function's accuracy. Use of one of the (many) MCU Timers proves much better - and you are an accomplished MCU Timer savant now - are you not?

  • Yes, it is surprising that so many counts are lost. Maybe something else is going on, but I don't know what.
    The SysCtlDelay should be about 0.1s I believe. (I realize that it's approximate - I just wanted something quick and easy and it was better than a for loop). My input frequency is 10 kHz, so I expect about 1000 counts per the delay. 0x7d0 = 2000. The UARTprintf() is likely quite slow. Anyway, it seems that the disable/re-enable caused counts to be missed, but I'll keep looking at it.

    Thanks again for your help!! Without you and Amit, I would likely still be stuck.
  • When I simplify the loop and use the ROM version of SysCtlDelay (somewhat more accurate), I get:

    while(1)
    {
    ui32Count = TimerValueGet(TIMER1_BASE, TIMER_A);

    UARTprintf("%x ", ui32Count);
    HWREG(0x40031050) = 0; // clear GPTM Timer A Value
    ROM_SysCtlDelay(SysCtlClockGet()/30);
    }

    Edge count example
    0 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e9 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e9 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e9 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8 3e8

    0x3e8 = 1007 and with a 10kHz input, I expect 1000 counts for the delay. The UARTprintf is not being timed since I clear the count afterward. (But in the UP counting example where the Timer is not reset, the UARTprintf delay does come into it.)

    Now, when I surround the HWREG instruction with
    ROM_TimerDisable(TIMER1_BASE, TIMER_A);
    HWREG(0x40031050) = 0; // clear GPTM Timer A Value
    ROM_TimerEnable(TIMER1_BASE, TIMER_A);

    I still get 0x3e8 for the count. It wasn't the disable/re-enable! (You were right to question it!!) Perhaps what happened was that I actually cleared the timer before the UARTprintf() when I got the extra long delay. I think that would explain why the result was consistent with the UP count where the UARTprintf() delay is in the loop. I did several trials so I probably posted code from a different trial. Good eye!
    Thanks again.
  • Final answer:
    //*****************************************************************************

    #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/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/timer.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"

    //*****************************************************************************
    //! UART0, connected to the Virtual Serial Port and running at 115,200, 8-N-1,
    //! is used to display messages from this application.
    //
    //*****************************************************************************

    //*****************************************************************************
    //
    // The error routine that is called if the driver library encounters an error.
    //
    //*****************************************************************************
    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
    }
    #endif

    //*****************************************************************************
    //
    // Configure the UART and its pins. This must be called before UARTprintf().
    //
    //*****************************************************************************
    void
    ConfigureUART(void)
    {
    //
    // Enable the GPIO Peripheral used by the UART.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    //
    // Enable UART0
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

    //
    // Configure GPIO Pins for UART mode.
    //
    ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
    ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
    ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Use the internal 16MHz oscillator as the UART clock source.
    //
    UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);

    //
    // Initialize the UART for console I/O.
    //
    UARTStdioConfig(0, 115200, 16000000);
    }

    //*****************************************************************************
    //
    //*****************************************************************************
    int
    main(void)
    {
    volatile uint32_t ui32Count, ui32LastCount;

    //
    // Enable lazy stacking for interrupt handlers. This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
    ROM_FPULazyStackingEnable();

    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
    SYSCTL_XTAL_16MHZ);

    //
    // Initialize the UART and write status.
    //
    ConfigureUART();

    UARTprintf("\033[2JEdge count example\n");

    //
    // Enable the GPIO port that is used for the on-board LED.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    //
    // Enable the GPIO pins for the LED (PF2 & PF1).
    //
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_1);


    //
    // Enable the peripherals used by this example.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);


    GPIOPinConfigure(GPIO_PB4_T1CCP0);
    ROM_GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_4);


    GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

    ROM_TimerConfigure(TIMER1_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT_UP));

    ROM_TimerControlEvent(TIMER1_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
    ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, 0xFFFF);
    ROM_TimerMatchSet(TIMER1_BASE, TIMER_A, 0xFFFE);
    ROM_TimerPrescaleSet(TIMER1_BASE, TIMER_A, 0xFF);
    ROM_TimerPrescaleMatchSet(TIMER1_BASE, TIMER_A, 0xFE);
    ROM_TimerIntClear(TIMER1_BASE, TIMER_CAPA_MATCH);

    ROM_TimerEnable(TIMER1_BASE, TIMER_A);

    ui32LastCount = 0;

    while(1)
    {
    // Get the current timer count.

    ui32Count = TimerValueGet(TIMER1_BASE, TIMER_A);

    UARTprintf("%x ", ui32Count);
    ROM_TimerDisable(TIMER1_BASE, TIMER_A);
    HWREG(0x40031050) = 0; // clear GPTM Timer A Value
    ROM_TimerEnable(TIMER1_BASE, TIMER_A);
    ROM_SysCtlDelay(SysCtlClockGet()/30);
    }
    }
  • Lance Halsted said:

    GPIOPinConfigure(GPIO_PB4_T1CCP0);
    ROM_GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_4);
    GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

    I'm not sure of the efficacy of "GPIOPadConfigSet()."   (suspect that the earlier "PinTypeTimer" properly handles that - and that some of its effort may be "undone.")

    We're glad that you persisted - and your clear, detailed SOLUTION presentation HERE is especially welcomed!   Well done.