I want to resad the GPIO Pin and if there is high pulse at my pin.(from my sensor)...i want detect and count the time for which it stays high....
first i have to give the 10us high pulse and then read the pin...repeat whole sequence for at least every 65ms period...
I have written this code.....
#define PART_LM4F120H5QR true
#include "inc/hw_ints.h"
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.c"
#include "driverlib/gpio.c"
#include "driverlib/timer.h"
#include "driverlib/pin_map.h"
#include "driverlib/interrupt.c"
#include "driverlib/cpu.c"
#include "driverlib/rom.h"
unsigned long int count,ON_PERIOD[],j;
unsigned int i=0;
int main(void)
{
ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_5);
GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_4);
while(1)
{
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4,GPIO_PIN_4); //make pin high for 10us for trigger
SysCtlDelay(800);
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4,~GPIO_PIN_4); //make it low for nearly 65 ms delay and read pin PE5
SysCtlDelay(1600000);
j=3500000;
while(j!=0)
{
while(GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_5)) //read pin PE5 and if high start up cuounting
{
ROM_TimerConfigure(WTIMER1_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_ONE_SHOT_UP);
ROM_TimerEnable(WTIMER1_BASE, TIMER_A);
}
count=ROM_TimerValueGet(WTIMER1_BASE, TIMER_A); //after pin is low ...get the counter value
j--;
}
ON_PERIOD[i]=count; // save count value in array
i++;
}
}
and how can i check the the count value....what i had done is right.....i don't know how can i check count value...
Please help....
thanx...