I am using Stellaris LM4F120H5QR
I want to get the time of a pulse given as input on PC4
I have written the following code and also made necessarry changes in startup_ccs.c but still can't get the light blinking on a high pulse , why is this so?
#define PART_LM4F120H5QR
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_timer.h"
#include "inc/hw_ints.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/adc.h"
#include "driverlib/timer.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
unsigned long ul_counter=0;
int check=0;
void
InitConsole(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_6);
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6,0x00);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTStdioInit(0);
}
void disp()
{
UARTprintf("***************************************************************************\n");
UARTprintf(" Author : A^2 \n");
UARTprintf(" Pulse Width Measurement\n");
UARTprintf(" Update Rate: to be displayed\n");
UARTprintf(" Input Pin: AIN0/PE3\n");
UARTprintf(" Initialising.");
UARTprintf("\n");
UARTprintf("***************************************************************************\n");
}
void Timer_Setup(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
TimerConfigure(TIMER0_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_B_PERIODIC);
TimerLoadSet(TIMER0_BASE, TIMER_B, SysCtlClockGet() / 10);
IntMasterEnable();
TimerIntEnable(TIMER0_BASE, TIMER_TIMB_TIMEOUT);
IntEnable(INT_TIMER0B);
}
void Timer0IntHandler(void)
{
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
ul_counter++;
}
void CCPIntHandler(void)
{ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2,0xFF);
TimerEnable(TIMER0_BASE, TIMER_B);
check=1;
}
void main(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_4);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);
// Set the clocking to run at 20 MHz (200 MHz / 10) using the PLL.
SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
InitConsole();
disp();
Timer_Setup();
GPIOIntTypeSet(GPIO_PORTC_BASE, GPIO_PIN_4, GPIO_HIGH_LEVEL);
GPIOPortIntRegister(GPIO_PORTC_BASE, CCPIntHandler);
while(1)
{
if((GPIOPinIntStatus(GPIO_PORTC_BASE, 0)==16)&&(check==1))
{
TimerQuiesce(TIMER0_BASE);
Timer_Setup();
check=0;
}
}
}