I have discovered that there is something interfering with the IFS0bits.T5IF event flag
Here is the set up:
A clean signal generator, square wave, that I'm watching with an O-scope, and let's say for this instance it's 6Khz
I have this code:
// timer is on
while (TMR5 == 0); //wait here until the signal goes high
while (IFS0bits.T5IF ==0); //wait here until the falling edge of the signal, which sets the T5IF high and TMR5 counter has already stopped
tft.print(counter_base/TMR5); //in this case my counter_base is 20,000,000 and TMR5 holds the count; I chose a 2:1 pre scale on PBCLK in this case
// then turn everything off
Most of the samples shows a value close to 6000; I don't need that much accuracy
then, on some occasions I'll see 31,554 or 500,000 or 21,332 or some equally strange number and then it will go back to something close to 6000 again
I'll keep at this, unless engineering knows that I can never get there from here :-)
Here is the set up:
A clean signal generator, square wave, that I'm watching with an O-scope, and let's say for this instance it's 6Khz
I have this code:
// timer is on
while (TMR5 == 0); //wait here until the signal goes high
while (IFS0bits.T5IF ==0); //wait here until the falling edge of the signal, which sets the T5IF high and TMR5 counter has already stopped
tft.print(counter_base/TMR5); //in this case my counter_base is 20,000,000 and TMR5 holds the count; I chose a 2:1 pre scale on PBCLK in this case
// then turn everything off
Most of the samples shows a value close to 6000; I don't need that much accuracy
then, on some occasions I'll see 31,554 or 500,000 or 21,332 or some equally strange number and then it will go back to something close to 6000 again
I'll keep at this, unless engineering knows that I can never get there from here :-)
Comment