Part Number: TM4C129DNCPDT
Hi,
I am trying to measure the frequency.
Range: Up to 12mHz
I have tried 3 method
1. FW polling the input gpio pin, count the clock, this way can measure about 5~6 mHz frequency input.
2.Set gpio as interrupt, when the frequency over 2mHz, system hang.
3.Use ccp pin and timer to count the clock, it is good from 100~2.1mHz
When the input frequency over 2.2mHz, the counter didn't work.
Return value from TimerValueGet(TIMER3_BASE, TIMER_A) didn't come down.
System clock is 120mHz
Could someone give any advice for this?
uint32_t elapsedHi_us, elapsedLoStart_us, elapsedLoEnd_us;
uint32_t nStopTime_us, nCycCount = 0;
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
Wait(10);
GPIOPinConfigure(GPIO_PD4_T3CCP0);
GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_4); // PD4
TimerDisable(TIMER3_BASE, TIMER_A);
TimerConfigure(TIMER3_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_CAP_COUNT);
TimerControlEvent(TIMER3_BASE,TIMER_A,TIMER_EVENT_POS_EDGE);
TimerLoadSet(TIMER3_BASE, TIMER_A, 65000);
TimerMatchSet(TIMER3_BASE, TIMER_A, 0);
TimerLoadSet(TIMER3_BASE, TIMER_A, 65000);
ROM_IntMasterDisable();
SysTimeStamp* pTs = SysTimeStamp::GetPtr();
pTs->Reset();
pTs->GetTimeStamp( &elapsedHi_us, &elapsedLoStart_us );
TimerEnable(TIMER3_BASE, TIMER_A);
do
{
pTs->GetTimeStamp( &elapsedHi_us, &elapsedLoEnd_us );
}while((elapsedLoEnd_us-elapsedLoStart_us)<10001); // 10ms
nCycCount = TimerValueGet(TIMER3_BASE, TIMER_A);
nCycCount = (uint32_t)65000 - nCycCount;
TimerDisable(TIMER3_BASE, TIMER_A);
ROM_IntMasterEnable();
*freq = nCycCount*100;