External interfacing/freqmod.o problems



 
John Murphy wrote:
> Do I need to implement software to catch and hide this wrap assuming
> periodic execution at high enough rate to see the wrap, or does EMC have
> some way of handling this.
 
Following function "expands" a 16 bit hardware counter to a 32bit long.
What we do here is just measure the displacement that the counter has count (wich can be positive or negative) between two succesive reads and add this to a long variable. The counter may not exceed 65536 / 2 counterpulses between 2 reads.
I use this short routine for expanding a 8 bit counter...

 
long Counter;   // global variable counter
 
void Count(void)
{
  int HwCounter, Displacement;

  ActualCounter = ReadHardwareCounter();
  Displacement = ActualCounter  - PreviousCounter;
  Counter + (long)Displacement
  PrevCounter = Counter;
}
 
Luc


Date Index | Thread Index | Back to archive index | Back to Mailing List Page

Problems or questions? Contact