Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

Timer Capture Mode for pulse capture

$
0
0

i am writing a code for pulse capture using the timer CCp of lm4f120h5qr launchpad board and it shows some arbitary vaue; What is wrong with the code??
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/rom.h"
#include "utils/ustdlib.h"
#include "utils/ustdlib.c"
#include "driverlib/uart.h"

#define GPIO_PA0_U0RX 0x00000001
#define GPIO_PA1_U0TX 0x00000401

void main(void)
{
//unsigned long ulPeriod;

//sysytem clock set
SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);

//SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);

//SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_6);

SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
TimerControlEvent(TIMER0_BASE, TIMER_A,TIMER_EVENT_BOTH_EDGES);

//ulPeriod = (SysCtlClockGet() / 10000) / 2;
//TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod -1);

//IntEnable(INT_TIMER0A);
//TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
//IntMasterEnable();


//enable timer start
TimerEnable(TIMER0_BASE, TIMER_A);
unsigned long a = TimerValueGet(TIMER0_BASE, TIMER_A);

//UART PART TRANSMISSION

char schar;
char b;
// int i;
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);

GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
UARTCharPut(UART0_BASE, '!');


do
{ //UARTCharPut(UART0_BASE, c);
//for(i=1;i<8;i++)
{
//b= am[i];

schar= UARTCharGet(UART0_BASE);
schar = 'a';
//c='X';
// UARTCharPut(UART0_BASE, am[0]);
UARTCharPut(UART0_BASE, am[1]);
UARTCharPut(UART0_BASE, am[2]);
UARTCharPut(UART0_BASE, am[3]);
UARTCharPut(UART0_BASE, am[4]);
UARTCharPut(UART0_BASE, am[5]);
UARTCharPut(UART0_BASE, am[6]);
UARTCharPut(UART0_BASE, am[7]);
UARTCharPut(UART0_BASE, schar);


// UARTCharPut(UART0_BASE, c);

}
} while((b != '\n') && (b != '\r'));


UARTCharPut(UART0_BASE, '@');




}


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>