Hii all
I am using
Tiva C series arm cortex M4 TM4C123GH6PM Launchpad. i wrote a code to measure frequency of input pulse given at Port F pin 4. compiler is not showing any error but i m not getting desired result. kindly help.
#include<tm4c123gh6pm.h>
#include<stdbool.h>
#include<stdint.h>
#include<interrupt.h>
#include<sysctl.h>
#include<gpio.h>
#include<hw_memmap.h>
#include<timer.h>
void PortFIntHandler(void);
void PortFInit(void);
void TimerInit(void);
volatile unsigned long ui32Loop,Count,f;
float Freq;
int main(void){
PortFInit(); // initialize GPIO Port F interrupt
while(1)
{}
}
void PortFInit(void){
IntDisable(INT_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,GPIO_PIN_4);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_3);
GPIO_PORTF_PUR_R |= 0x10; // enable weak pull-up on PF4
IntEnable(INT_GPIOF);
GPIOIntEnable(GPIO_PORTF_BASE | GPIO_PIN_4, GPIO_FALLING_EDGE);
}
void PortFIntHandler(void){
if(f!=1)
TimerInit();
else
{
GPIO_PORTF_ICR_R = 0x10; // acknowledge flag4
Count=TimerValueGet(TIMER0_BASE, TIMER_A);
Freq=80000000/Count;
TimerInit();
f=1;
}}
void TimerInit(void)
{
TimerDisable(TIMER0_BASE,TIMER_A);
TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC_UP);
TimerLoadSet(TIMER0_BASE, TIMER_A, 0xFFFFFFFF);
TimerEnable(TIMER0_BASE, TIMER_A);
}