HI,Sir i am trying to interface tv remote to tiva.For that purpose i have connected my TSOP SM0038 IR sensor on the PD2 PIN.To count the number of pulses received on IR SENSOR(TSOP),I am using timer wtimer3 which is on pin no PD2 and diplaying the count of pulses on my serial monitor using UART. SIR,,,Im not gettting any o/p on my serial monitor...?
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/adc.h"
#include "driverlib/uart.h"
#include "driverlib/interrupt.h"
#include "utils/uartstdio.h"
#include "inc/hw_timer.h"
#include "driverlib/timer.h"
#include "inc/hw_ints.h"
#include "driverlib/pin_map.h"
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 WTimer3AIntHandler(void)
{
int count=0,state=0;
// Clear the timer interrupt
TimerIntClear(WTIMER3_BASE,TIMER_CAPA_EVENT);
count=TimerValueGet(WTIMER3_BASE,TIMER_A);
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)
{
/*Set the clocking to run at 80Mhz from the crystal of 16MHz using PLL*/
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
/* Set the clock for the GPIO Port F */
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
/* Set the type of the GPIO Pin */
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_2);
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1,0);
//TimerDisable(WTIMER1_BASE, TIMER_A);
SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER3);
/*Configure GPIO pad with internal pull-up enabled*/
GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_2, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
//GPIOIntTypeSet(GPIO_PORTD_BASE, GPIO_PIN_2, GPIO_FALLING_EDGE);
TimerConfigure(WTIMER3_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PERIODIC|TIMER_CFG_A_CAP_COUNT);
TimerControlEvent(WTIMER3_BASE,TIMER_A,TIMER_EVENT_NEG_EDGE);
/* UART config */
InitConsole();
IntMasterEnable();
TimerIntRegister(WTIMER3_BASE, TIMER_A, WTimer3AIntHandler);
TimerIntEnable(WTIMER3_BASE, TIMER_CAPA_EVENT);
IntEnable(INT_WTIMER3A);
TimerEnable(WTIMER3_BASE,TIMER_A);
while(1)
{
}
}