Hi,,i want to use a capture count timer to count the no of negative edges...and display it on my screen using uart.For this i have configured timer0 as count timer and timer1 as in pwm mode...BUT the problem is nothing is being displayed on screen.
my code is :::::::::::::::
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_timer.h"
#include "inc/hw_ints.h"
#include "inc/hw_gpio.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "utils/uartstdio.h"
#include "driverlib/pin_map.h"
unsigned long int count=0,state=0;
void
InitConsole(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
/* Make the UART pins be peripheral controlled. */
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Initialize the UART for console I/O.
//
UARTStdioInit(0);
}
void timer_int(void)
{
TimerIntClear(TIMER0_BASE,TIMER_CAPB_EVENT);
count=TimerValueGet(TIMER0_BASE,TIMER_B);
UARTprintf("count elapsed : %d \n",count);
if(state)
{GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,0);
state=0;
}
else {GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_PIN_1);
state=1;
}
}
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_1| SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);//16 mhz
InitConsole();
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
GPIOPinConfigure(GPIO_PB4_T1CCP0);
GPIOPinConfigure(GPIO_PF1_T0CCP1);
GPIOPinTypeTimer(GPIO_PORTB_BASE,GPIO_PIN_4);
GPIOPinTypeTimer(GPIO_PORTF_BASE,GPIO_PIN_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_B_PWM);
TimerConfigure(TIMER0_BASE, TIMER_CFG_16_BIT_PAIR |TIMER_CFG_B_CAP_COUNT);
TimerLoadSet(TIMER1_BASE, TIMER_B, 40000);
TimerLoadSet(TIMER0_BASE, TIMER_B, 40000);
TimerMatchSet(TIMER1_BASE, TIMER_B, TimerLoadGet(TIMER1_BASE, TIMER_B) / 2);
TimerMatchSet(TIMER0_BASE, TIMER_B, 1);
TimerControlEvent(TIMER0_BASE,TIMER_B,TIMER_EVENT_NEG_EDGE);
TimerEnable(TIMER1_BASE, TIMER_B);
TimerIntEnable(TIMER0_BASE,TIMER_CAPB_EVENT);
TimerIntRegister(TIMER0_BASE,TIMER_B,timer_int);
TimerEnable(TIMER0_BASE, TIMER_B);
IntMasterEnable();
/* UART config */
InitConsole();
while(1)
{
}
}