HI,
i have problem with counter.......the result shows keep decreasing value.....
Can someone help me to check what is my problem ?
Description:
When comparator output rising edge then counter will +1.....
Below is my coding:
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/pin_map.h"
#include "driverlib/comp.h"
#include "driverlib/debug.h"
#include "driverlib/timer.h"
unsigned long g_ulFlags;
unsigned long timer;
#ifdef DEBUG
void
__error__(char *pcFilename, unsigned long ulLine)
{
}
#endif
char display[50];
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIODirModeSet(GPIO_PORTF_BASE, 0x01, GPIO_DIR_MODE_OUT);
GPIOPadConfigSet(GPIO_PORTF_BASE, 0x01,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD);
HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= 0x01;
HWREG(GPIO_PORTF_BASE + GPIO_O_DEN) |= 0x01;
HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0;
HWREG(GPIO_PORTF_BASE + GPIO_O_AFSEL) |= 0x1;
HWREG(GPIO_PORTF_BASE + GPIO_O_PCTL) &= ~(0xF);
HWREG(GPIO_PORTF_BASE + GPIO_O_PCTL) |= 0x9;
GPIOPinTypeGPIOOutput (GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_COMP0);
ComparatorConfigure(COMP_BASE, 0,
(COMP_TRIG_NONE | COMP_INT_BOTH | COMP_ASRCP_REF | COMP_OUTPUT_INVERT));
ComparatorRefSet(COMP_BASE, COMP_REF_0V);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
GPIOPinConfigure(GPIO_PF4_T2CCP0);
GPIOPinTypeTimer(GPIO_PORTF_BASE, GPIO_PIN_4);
TimerConfigure(TIMER2_BASE, TIMER_CFG_A_CAP_COUNT);
TimerLoadSet(TIMER2_BASE, TIMER_A, 1);
TimerControlEvent(TIMER2_BASE,TIMER_A,TIMER_EVENT_POS_EDGE);
TimerEnable(TIMER2_BASE, TIMER_A);
while(1)
{
timer=TimerValueGet(TIMER2_BASE,TIMER_A);
}
}
Regards,
Dorene