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.

TM4C123G DK-EVB Timer Question

Dear all 

i'm use TM123G DK-EVB and Keil Tools

 I  want   input edge Count  by Up-Key Button(PM0)  in DK-EVB 

 it's no Update value TAR & TAV in Timer Register

Let me know problem ?

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

//*****************************************************************************
//
// 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);
}


//*****************************************************************************
//
// The interrupt handler for the first timer interrupt.
//
//*****************************************************************************
void
Timer0IntHandler(void)
{


// Clear the timer interrupt.

ROM_TimerIntClear(TIMER4_BASE, TIMER_CAPA_MATCH);

// GPIO G-Port PG2 (High) for User LED On
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, 0x04);

UARTprintf("Timer4, Timer A INT Enter ");

ROM_IntMasterEnable();
}

//*****************************************************************************
//
// The interrupt handler for the first timer interrupt.
//
//*****************************************************************************
void
Timer1IntHandler(void)
{


// Clear the timer interrupt.

ROM_TimerIntClear(TIMER4_BASE, TIMER_CAPA_MATCH);

// GPIO G-Port PG2 (High) for User LED Off
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, 0x04 ^ 0xFF);

UARTprintf("Timer4 ,Time B INT Enter ");

ROM_IntMasterEnable();
}

int
main(void)
{

// 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();

// Set the clocking to run directly from the crystal.
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);


// GPIO port use Define ( Port-G(LED), Port-M(T4CCP0 PM0(89Pin))

// System Control Peripheral GPIO " G-Port " Enable
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);

// System Control Peripheral GPIO " M-Port " Enable
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);

// GPIOPin to Timer Seting
ROM_GPIOPinTypeTimer(GPIO_PORTM_BASE, GPIO_PIN_0);

// GPIO Alternate Function , Timer4 CCP pin : T4CCP0 , TimerA
ROM_GPIOPinConfigure(GPIO_PM0_T4CCP0);

// Port-M, (PM0, PM1, PM2, PM3), INPUT Set
ROM_GPIOPinTypeGPIOInput(GPIO_PORTM_BASE,GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);

// Port-M, (PM0, PM1, PM2, PM3), Pull-Up Set
ROM_GPIOPadConfigSet(GPIO_PORTM_BASE, GPIO_PIN_0 |GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);

// Port-G ,Pin2, Direction Output Set
ROM_GPIODirModeSet(GPIO_PORTG_BASE, GPIO_PIN_2, GPIO_DIR_MODE_OUT );

// Port-G, Pin2 , GPIO-Out Set
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE ,GPIO_PIN_2);

// Uart intial seting UART0, Port-A, PA0 (RX), PA1(TX)
ConfigureUART();


// System Control peripherals " Timer4 " Enable.
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER4);

// Enable processor interrupts.
ROM_IntMasterEnable();

// GPIO M port(PM0) Timer4 , CCP-Pin T4CCP0, A Timer , 16/32bit Timet Capture Count Up
ROM_TimerConfigure(TIMER4_BASE, (TIMER_CFG_SPLIT_PAIR |TIMER_CFG_A_PERIODIC_UP | TIMER_CFG_A_CAP_COUNT_UP));

// T4CCP0-Pin Event Negertive Edge Set
ROM_TimerControlEvent(TIMER4_BASE, TIMER_A, TIMER_EVENT_NEG_EDGE);

// Timer4 Timer A , Load Value Set ,
ROM_TimerLoadSet(TIMER4_BASE, TIMER_A, 17);

// Timer4 Timer A Match Value Set
ROM_TimerMatchSet(TIMER4_BASE, TIMER_A, 2);

// Setup the interrupts for Timer4 , Timer A
ROM_IntEnable(INT_TIMER4A);

// Timer4 Interrupt Source Enable ; Capture A match
ROM_TimerIntEnable(TIMER4_BASE, TIMER_CAPA_MATCH);

// Enable the timer (Timer4 , Timer A)
ROM_TimerEnable(TIMER4_BASE, TIMER_A);


// Test Interrupt handler for Inturrupt
//TimerIntRegister(TIMER4_BASE, TIMER_A, Timer0IntHandler);


// Loop forever while the timers run.
while(1)
{
   / /UARTprintf("Test \n");
}

}