Other Parts Discussed in Thread: TM4C1294NCPDT
Tool/software: Code Composer Studio
I have written code for capturing 50 HZ pulse using TIMER. But, the code is not going to Interrupt handler function. Also, I have done changes accordingly in startup.css for the same.
Please, look into it as soon as possible.
#define PART_TMC123GH6PM
#include <stdint.h> // Variable definitions for the C99 standard.
#include <stdio.h> // Input and output facilities for the C99 standard.
#include <stdbool.h> // Boolean definitions for the C99 standard.
//#include "inc/hw_ints.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/pwm.h"
#include "driverlib/sysctl.h" // Definitions and macros for System Control API of DriverLib.
#include "driverlib/interrupt.h" // Defines and macros for NVIC Controller API of DriverLib.
#include "driverlib/gpio.h" // Definitions and macros for GPIO API of DriverLib.
#include "driverlib/timer.h" // Defines and macros for Timer API of DriverLib.
#include "driverlib/pin_map.h" //Mapping of peripherals to pins for all parts.
#include "driverlib/adc.h" // Definitions for ADC API of DriverLib.
#include "driverlib/fpu.h" // Prototypes for the FPU manipulation routines.
#include "inc/tm4c123gh6pm.h" // Definitions for the interrupt and register assignments.
#include "inc/hw_memmap.h" // Memory map definitions of the Tiva C Series device.
#include "inc/hw_types.h" // Definitions of common types and macros.
uint32_t g_ui32SysClock;
int pulse_time_1=0;
int a = 0, b = 0, c = 0;
void TIMER_Initialize(void)
{
// Enables timer 1
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER0))
{
}
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOL))
{
}
// Timer type set
GPIOPinTypeTimer(GPIO_PORTL_BASE, GPIO_PIN_4);
// PB5 pin configured with timer 1
GPIOPinConfigure(GPIO_PL4_T0CCP0);
// Configure timer to edge time capture
TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_CAP_TIME);
// Event set to both pulse edges
TimerControlEvent(TIMER0_BASE, TIMER_B, TIMER_EVENT_BOTH_EDGES);
// Enables the timers
TimerEnable(TIMER0_BASE, TIMER_B);
// Configure timer 1b interrupts
IntEnable(INT_TIMER0B);
// Enable timer interrupts
TimerIntEnable(TIMER0_BASE, TIMER_CAPB_EVENT);
// Enables processor interrupts
IntMasterEnable();
}
int main(void)
{
// SysCtlClockSet(SYSCTL_SYSDIV_64 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
g_ui32SysClock = SysCtlClockFreqSet(( SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
TIMER_Initialize();
while (1)
{
// pulse_time_1 = TimerLoadGet(TIMER0_BASE, TIMER_B);
// TimerEnable(TIMER0_BASE, TIMER_B);
}
}
void Timer3IntHandler(void)
{
TimerIntClear(TIMER0_BASE, TIMER_CAPB_EVENT);
b = TimerValueGet(TIMER0_BASE, TIMER_B);
if (b < a)
c = 65535 + a - b;
else
c = a - b;
pulse_time_1 = c / 3125;
a = TimerValueGet(TIMER0_BASE, TIMER_B);
}
Thanks & Regards
Vinayak